diff --git a/src/Jobs/Handler/SendCourseCommunication.hs b/src/Jobs/Handler/SendCourseCommunication.hs index fbaa04578..2c22624ed 100644 --- a/src/Jobs/Handler/SendCourseCommunication.hs +++ b/src/Jobs/Handler/SendCourseCommunication.hs @@ -31,7 +31,7 @@ dispatchJobSendCourseCommunication jRecipientEmail jAllRecipientAddresses jCours MsgRenderer mr <- getMailMsgRenderer void $ setMailObjectUUID jMailObjectUUID - _mailReplyTo .= (userAddressFrom sender ^. _addressEmail) + _mailReplyTo .= userAddressFrom sender addMailHeader "Cc" [st|#{mr MsgCommUndisclosedRecipients}:;|] addMailHeader "Auto-Submitted" "no" setSubjectI . prependCourseTitle courseTerm courseSchool courseShorthand $ maybe (SomeMessage MsgCommCourseSubject) SomeMessage jSubject diff --git a/src/Mail.hs b/src/Mail.hs index f90b86aae..ec9c93e2f 100644 --- a/src/Mail.hs +++ b/src/Mail.hs @@ -32,7 +32,7 @@ module Mail , setDate, setDateCurrent , getMailSmtpData , _addressName, _addressEmail - , _mailFrom, _mailTo, _mailCc, _mailBcc, _mailReplyTo, _mailHeaders, _mailHeader, _mailParts + , _mailFrom, _mailTo, _mailCc, _mailBcc, _mailReplyTo, _mailReplyTo', _mailHeaders, _mailHeader, _mailParts , _partType, _partEncoding, _partDisposition, _partFilename, _partHeaders, _partContent ) where @@ -139,24 +139,24 @@ _partFilename = _partDisposition . dispositionFilename _mailHeader :: CI ByteString -> Traversal' Mail Text _mailHeader hdrName = _mailHeaders . traverse . filtered (views _1 $ (== hdrName) . CI.mk) . _2 -_mailReplyTo :: Lens' Mail Text +_mailReplyTo' :: Lens' Mail Text +_mailReplyTo' = _mailHeaders . _headerReplyTo' + +_headerReplyTo' :: Lens' Headers Text +-- Functor f => (Text -> f Text) -> [(ByteString, Text)] -> f [(ByteString, Text)] +_headerReplyTo' f hdrs = (\x -> insertAssoc (replyto,x) hdrs) <$> f (maybeMonoid $ lookup replyto hdrs) + where + replyto = "Reply-To" + +_mailReplyTo :: Lens' Mail Address _mailReplyTo = _mailHeaders . _headerReplyTo -_headerReplyTo :: Lens' Headers Text --- Lens' [(ByteString, Text)] Text --- Functor f => (Text -> f Text) -> [(ByteString, Text)] -> f [(ByteString, Text)] -_headerReplyTo f hdrs = (\x -> insertAssoc (replyto,x) hdrs) <$> f (maybeMonoid $ lookup replyto hdrs) - where - replyto = "Reply-To" - --- _addressEmail :: Lens' Address Text -_headerReplyTo' :: Lens' Headers Address --- Lens' [(ByteString, Text)] Address +_headerReplyTo :: Lens' Headers Address -- Functor f => (Address -> f Address) -> [(ByteString, Text)] -> f [(ByteString, Text)] -_headerReplyTo' f hdrs = (\x -> insertAssoc (replyto,renderAddress x) hdrs) <$> f (fromString $ unpack $ maybeMonoid $ lookup replyto hdrs) +_headerReplyTo f hdrs = (\x -> insertAssoc (replyto,renderAddress x) hdrs) <$> f (fromString $ unpack $ maybeMonoid $ lookup replyto hdrs) where replyto = "Reply-To" - + -- _addressEmail :: Lens' Address Text might help to simplify this code? newtype MailT m a = MailT { _unMailT :: RWST MailContext MailSmtpData Mail m a } deriving newtype ( MonadTrans, Monad, Functor, MonadFail, Applicative, Alternative, MonadPlus