@@ -92,6 +92,7 @@ import qualified Data.Text.Lazy as TL
9292import qualified Data.Text.Lazy.Encoding as TL
9393import qualified Data.Vector as Vec
9494
95+
9596-- A feature to manage notifications to users when package metadata, etc is updated.
9697
9798{-
@@ -448,7 +449,7 @@ initUserNotifyFeature env@ServerEnv{ serverStateDir, serverTemplatesDir,
448449 -- Page templates
449450 templates <- loadTemplates serverTemplatesMode
450451 [serverTemplatesDir, serverTemplatesDir </> " UserNotify" ]
451- [ " user-notify-form.html" ]
452+ [ " user-notify-form.html" , " endorsements-complete.txt " ]
452453
453454 return $ \ users core uploadfeature adminlog userdetails reports tags revers vouch -> do
454455 let feature = userNotifyFeature env
@@ -716,7 +717,7 @@ userNotifyFeature serverEnv@ServerEnv{serverCron}
716717 vouchNotifications <- fmap (, NotifyVouchingCompleted ) <$> drainQueuedNotifications
717718
718719 emails <-
719- getNotificationEmails serverEnv userDetailsFeature users $
720+ getNotificationEmails serverEnv userDetailsFeature users templates $
720721 concat
721722 [ revisionUploadNotifications
722723 , groupActionNotifications
@@ -924,18 +925,20 @@ getNotificationEmails
924925 :: ServerEnv
925926 -> UserDetailsFeature
926927 -> Users. Users
928+ -> Templates
927929 -> [(UserId , Notification )]
928930 -> IO [Mail ]
929931getNotificationEmails
930932 ServerEnv {serverBaseURI}
931933 UserDetailsFeature {queryUserDetails}
932934 allUsers
935+ templates
933936 notifications = do
934937 let userIds = Set. fromList $ map fst notifications
935938 userIdToDetails <- Map. mapMaybe id <$> fromSetM queryUserDetails userIds
936-
939+ vouchTemplate <- renderTemplate . ( $ [] ) <$> getTemplate templates " endorsements-complete.txt "
937940 pure $
938- let emails = groupNotifications $ map (fmap renderNotification) notifications
941+ let emails = groupNotifications $ map (fmap ( renderNotification vouchTemplate) ) notifications
939942 in flip mapMaybe (Map. toList emails) $ \ ((uid, group), emailContent) ->
940943 case uid `Map.lookup` userIdToDetails of
941944 Nothing -> Nothing
@@ -991,8 +994,8 @@ getNotificationEmails
991994
992995 {- ---- Render notifications -----}
993996
994- renderNotification :: Notification -> (EmailContent , NotificationGroup )
995- renderNotification = \ case
997+ renderNotification :: BS. ByteString -> Notification -> (EmailContent , NotificationGroup )
998+ renderNotification vouchTemplate = \ case
996999 NotifyNewVersion {.. } ->
9971000 generalNotification $
9981001 renderNotifyNewVersion
@@ -1031,7 +1034,7 @@ getNotificationEmails
10311034 )
10321035 NotifyVouchingCompleted ->
10331036 generalNotification
1034- renderNotifyVouchingCompleted
1037+ ( EmailContentParagraph . EmailContentText . T. pack $ BS. unpack vouchTemplate)
10351038
10361039 where
10371040 generalNotification = (, GeneralNotification )
@@ -1098,13 +1101,6 @@ getNotificationEmails
10981101 ]
10991102 <> EmailContentList (map renderPkgLink revDeps)
11001103
1101- renderNotifyVouchingCompleted =
1102- EmailContentParagraph
1103- " You have received all necessary endorsements. \
1104- \You have been added the the 'uploaders' group. \
1105- \You can now upload packages to Hackage. \
1106- \Note that packages cannot be deleted, so be careful."
1107-
11081104 {- ---- Rendering helpers -----}
11091105
11101106 renderPackageName = emailContentStr . unPackageName
0 commit comments