@@ -92,6 +92,7 @@ import qualified Data.Text.Lazy as TL
92
92
import qualified Data.Text.Lazy.Encoding as TL
93
93
import qualified Data.Vector as Vec
94
94
95
+
95
96
-- A feature to manage notifications to users when package metadata, etc is updated.
96
97
97
98
{-
@@ -448,7 +449,7 @@ initUserNotifyFeature env@ServerEnv{ serverStateDir, serverTemplatesDir,
448
449
-- Page templates
449
450
templates <- loadTemplates serverTemplatesMode
450
451
[serverTemplatesDir, serverTemplatesDir </> " UserNotify" ]
451
- [ " user-notify-form.html" ]
452
+ [ " user-notify-form.html" , " endorsements-complete.txt " ]
452
453
453
454
return $ \ users core uploadfeature adminlog userdetails reports tags revers vouch -> do
454
455
let feature = userNotifyFeature env
@@ -716,7 +717,7 @@ userNotifyFeature serverEnv@ServerEnv{serverCron}
716
717
vouchNotifications <- fmap (, NotifyVouchingCompleted ) <$> drainQueuedNotifications
717
718
718
719
emails <-
719
- getNotificationEmails serverEnv userDetailsFeature users $
720
+ getNotificationEmails serverEnv userDetailsFeature users templates $
720
721
concat
721
722
[ revisionUploadNotifications
722
723
, groupActionNotifications
@@ -924,18 +925,20 @@ getNotificationEmails
924
925
:: ServerEnv
925
926
-> UserDetailsFeature
926
927
-> Users. Users
928
+ -> Templates
927
929
-> [(UserId , Notification )]
928
930
-> IO [Mail ]
929
931
getNotificationEmails
930
932
ServerEnv {serverBaseURI}
931
933
UserDetailsFeature {queryUserDetails}
932
934
allUsers
935
+ templates
933
936
notifications = do
934
937
let userIds = Set. fromList $ map fst notifications
935
938
userIdToDetails <- Map. mapMaybe id <$> fromSetM queryUserDetails userIds
936
-
939
+ vouchTemplate <- renderTemplate . ( $ [] ) <$> getTemplate templates " endorsements-complete.txt "
937
940
pure $
938
- let emails = groupNotifications $ map (fmap renderNotification) notifications
941
+ let emails = groupNotifications $ map (fmap ( renderNotification vouchTemplate) ) notifications
939
942
in flip mapMaybe (Map. toList emails) $ \ ((uid, group), emailContent) ->
940
943
case uid `Map.lookup` userIdToDetails of
941
944
Nothing -> Nothing
@@ -991,8 +994,8 @@ getNotificationEmails
991
994
992
995
{- ---- Render notifications -----}
993
996
994
- renderNotification :: Notification -> (EmailContent , NotificationGroup )
995
- renderNotification = \ case
997
+ renderNotification :: BS. ByteString -> Notification -> (EmailContent , NotificationGroup )
998
+ renderNotification vouchTemplate = \ case
996
999
NotifyNewVersion {.. } ->
997
1000
generalNotification $
998
1001
renderNotifyNewVersion
@@ -1031,7 +1034,7 @@ getNotificationEmails
1031
1034
)
1032
1035
NotifyVouchingCompleted ->
1033
1036
generalNotification
1034
- renderNotifyVouchingCompleted
1037
+ ( EmailContentParagraph . EmailContentText . T. pack $ BS. unpack vouchTemplate)
1035
1038
1036
1039
where
1037
1040
generalNotification = (, GeneralNotification )
@@ -1098,13 +1101,6 @@ getNotificationEmails
1098
1101
]
1099
1102
<> EmailContentList (map renderPkgLink revDeps)
1100
1103
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
-
1108
1104
{- ---- Rendering helpers -----}
1109
1105
1110
1106
renderPackageName = emailContentStr . unPackageName
0 commit comments