Skip to content

Commit e652a60

Browse files
brandonchinn178ysangkok
authored andcommitted
Improve email subject for dep update emails
1 parent 7a92fc1 commit e652a60

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/Distribution/Server/Features/UserNotify.hs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -699,14 +699,22 @@ userNotifyFeature ServerEnv{serverBaseURI, serverCron}
699699
idx <- queryGetPackageIndex
700700
revIdx <- liftIO queryReverseIndex
701701
dependencyUpdateNotifications <- Map.unionsWith (++) <$> traverse (genDependencyUpdateList idx revIdx . pkgInfoToPkgId) revisionsAndUploads
702-
dependencyEmails <- Map.mapKeys fst <$> Map.traverseWithKey describeDependencyUpdate dependencyUpdateNotifications
702+
dependencyEmails <- Map.traverseWithKey describeDependencyUpdate dependencyUpdateNotifications
703703

704704
-- Concat the constituent email parts such that only one email is sent per user
705-
mapM_ (sendNotifyEmailAndDelay users) . Map.toList $ foldr1 (Map.unionWith (++)) $ [revisionUploadEmails, groupActionEmails, docReportEmails, tagProposalEmails]
705+
mapM_ (sendNotifyEmailAndDelay users) . Map.toList $
706+
fmap ("Maintainer Notifications",) . foldr1 (Map.unionWith (++)) $
707+
[ revisionUploadEmails
708+
, groupActionEmails
709+
, docReportEmails
710+
, tagProposalEmails
711+
]
706712

707713
-- Dependency email notifications consist of multiple paragraphs, so it would be confusing if concatenated.
708714
-- So they're sent independently.
709-
mapM_ (sendNotifyEmailAndDelay users) . Map.toList $ dependencyEmails
715+
mapM_ (sendNotifyEmailAndDelay users) . Map.toList $
716+
Map.mapKeys fst . Map.mapWithKey (\(_, dep) ebody -> ("Dependency Update: " <> T.pack (display dep), ebody)) $
717+
dependencyEmails
710718

711719
updateState notifyState (SetNotifyTime now)
712720

@@ -862,8 +870,8 @@ userNotifyFeature ServerEnv{serverBaseURI, serverCron}
862870
]
863871
++ map display revDeps
864872

865-
sendNotifyEmailAndDelay :: Users.Users -> (UserId, [String]) -> IO ()
866-
sendNotifyEmailAndDelay users (uid, ebody) = do
873+
sendNotifyEmailAndDelay :: Users.Users -> (UserId, (T.Text, [String])) -> IO ()
874+
sendNotifyEmailAndDelay users (uid, (subject, ebody)) = do
867875
mudetails <- queryUserDetails uid
868876
case mudetails of
869877
Nothing -> return ()
@@ -872,8 +880,7 @@ userNotifyFeature ServerEnv{serverBaseURI, serverCron}
872880
(T.pack ("noreply@" ++ uriRegName ourHost))
873881
mail = (emptyMail mailFrom) {
874882
mailTo = [Address (Just aname) eml],
875-
mailHeaders = [(BSS.pack "Subject",
876-
T.pack "[Hackage] Maintainer Notifications")],
883+
mailHeaders = [(BSS.pack "Subject", "[Hackage] " <> subject)],
877884
mailParts = [[Part (T.pack "text/plain; charset=utf-8")
878885
None DefaultDisposition []
879886
(PartContent $ BS.pack $

0 commit comments

Comments
 (0)