From d4773f59699f606a43917475198d377dfd52f599 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Tue, 17 Sep 2024 10:23:26 -0500 Subject: [PATCH] Detect XDC by extension as well Since deltachat does, sometimes this is needed for now --- Email.hs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Email.hs b/Email.hs index 643c745..6447d7f 100644 --- a/Email.hs +++ b/Email.hs @@ -561,11 +561,16 @@ concatUnlessBig siz builder stream _ -> return $ Just $ LZ.toStrict $ BS.toLazyByteString builder -getHttpContentType :: HTTP.Response -> MIME.ContentType -getHttpContentType response = - fromMaybe MIME.contentTypeApplicationOctetStream $ - (hush . Atto.parseOnly MIME.parseContentType =<<) $ - HTTP.getHeader response (s"content-type") +getHttpContentType :: Text -> HTTP.Response -> MIME.ContentType +getHttpContentType url response + | ext == s"xdc" = + MIME.ContentType (s"application") (s"webxdc+zip") mempty + | otherwise = + fromMaybe MIME.contentTypeApplicationOctetStream $ + (hush . Atto.parseOnly MIME.parseContentType =<<) $ + HTTP.getHeader response (s"content-type") + where + ext = T.takeWhileEnd (/='.') url messageToAttachments :: (UIO.Unexceptional m) => XMPP.Message @@ -583,7 +588,7 @@ messageToAttachments message = catMaybes <$> return Nothing else (fmap . fmap) (Attachment - (getHttpContentType response) + (getHttpContentType url response) (T.takeWhileEnd (/='/') url)) (concatUnlessBig 0 mempty stream) ) -- 2.45.2