~singpolyma/cheogram-smtp

d4773f59699f606a43917475198d377dfd52f599 — Stephen Paul Weber 27 days ago f844e31 master
Detect XDC by extension as well

Since deltachat does, sometimes this is needed for now
1 files changed, 11 insertions(+), 6 deletions(-)

M Email.hs
M Email.hs => Email.hs +11 -6
@@ 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)
		)