~singpolyma/cheogram-smtp

217288d4a1c5e5bae1e40291d5ebdcd50f313e8c β€” Stephen Paul Weber 2 years ago 44a126d
Add Jabber-ID header
2 files changed, 7 insertions(+), 2 deletions(-)

M Email.hs
M test/EmailTest.hs
M Email.hs => Email.hs +2 -0
@@ 125,11 125,13 @@ messageToEmail fromDomain now message@XMPP.Message {
			typeHeaders message $
			set MIME.headerTo [toAddress] $
			set MIME.headerFrom [fromMailbox] $
			set (MIME.headers . at (s"Jabber-ID")) jidHeader $
			set (MIME.headers . at (s"Subject")) subjectHeader $
			set MIME.headerDate (Just dateHeader) $
			MIME.createTextPlainMessage bodyTxt
		)
	where
	jidHeader = Just $ MIME.encodeEncodedWords (bareTxt from)
	dateHeader = fromMaybe now $ parseXMPPTime =<<
		XML.attributeText (s"{urn:xmpp:delay}stamp") =<<
		child (s"{urn:xmpp:delay}delay") message

M test/EmailTest.hs => test/EmailTest.hs +5 -2
@@ 98,7 98,8 @@ unit_messageToEmailChat =
	email = s"MIME-Version: 1.0\r\n\
	\Chat-Version: 1.0\r\n\
	\To: t@example.com\r\n\
	\From: f=40example=2Ecom@gateway.example.com\r\n\
	\From: =E4=B8=96=40example=2Ecom@gateway.example.com\r\n\
	\Jabber-ID: =?utf-8?B?5LiWQGV4YW1wbGUuY29t?=\r\n\
	\Subject: =?utf-8?B?Q2hhdDog5LiW55WMCi4K?=\r\n\
	\date: Mon, 01 Jan 1990 00:00:00 +0000\r\n\
	\Content-Transfer-Encoding: base64\r\n\


@@ 109,7 110,7 @@ unit_messageToEmailChat =
	message = (XMPP.emptyMessage XMPP.MessageChat) {
		XMPP.messageTo =
			XMPP.parseJID $ s"t\\40example.com@gateway.example.com",
		XMPP.messageFrom = XMPP.parseJID $ s"f@example.com",
		XMPP.messageFrom = XMPP.parseJID $ s"δΈ–@example.com",
		XMPP.messagePayloads = [
			XML.Element (fromString "{jabber:component:accept}body")
			[] [


@@ 134,6 135,7 @@ unit_messageToEmailWithSubject =
	email = s"MIME-Version: 1.0\r\n\
	\To: t@example.com\r\n\
	\From: f=40example=2Ecom@gateway.example.com\r\n\
	\Jabber-ID: f@example.com\r\n\
	\Subject: =?utf-8?B?5LiW55WM?=\r\n\
	\date: Mon, 01 Jan 1990 00:00:00 +0000\r\n\
	\Content-Transfer-Encoding: base64\r\n\


@@ 174,6 176,7 @@ unit_messageToEmailWithDelay =
	email = s"MIME-Version: 1.0\r\n\
	\To: t@example.com\r\n\
	\From: f=40example=2Ecom@gateway.example.com\r\n\
	\Jabber-ID: f@example.com\r\n\
	\date: Sun, 22 Feb 2009 00:10:00 +0000\r\n\
	\Content-Transfer-Encoding: base64\r\n\
	\Content-Disposition: inline\r\n\