@@ -695,8 +695,7 @@ userNotifyFeature serverEnv@ServerEnv{serverCron}
695
695
groupActionNotifications <- concatMapM (genGroupUploadList notifyPrefs) groupActions
696
696
697
697
docReports <- collectDocReport trimLastTime now
698
- docReportNotifications <- foldM (genDocReportList notifyPrefs) Map. empty docReports
699
- let docReportEmails = foldMap describeDocReport <$> docReportNotifications
698
+ docReportNotifications <- concatMapM (genDocReportList notifyPrefs) docReports
700
699
701
700
tagProposals <- collectTagProposals
702
701
tagProposalNotifications <- concatMapM (genTagProposalList notifyPrefs) tagProposals
@@ -708,13 +707,14 @@ userNotifyFeature serverEnv@ServerEnv{serverCron}
708
707
emails <-
709
708
getNotificationEmails serverEnv userDetailsFeature queryGetUserNotifyPref users
710
709
( foldr1 (Map. unionWith (<>) )
711
- [ docReportEmails
710
+ [
712
711
]
713
712
, mempty
714
713
) $
715
714
concat
716
715
[ revisionUploadNotifications
717
716
, groupActionNotifications
717
+ , docReportNotifications
718
718
, tagProposalNotifications
719
719
, dependencyUpdateNotifications
720
720
]
@@ -817,14 +817,18 @@ userNotifyFeature serverEnv@ServerEnv{serverCron}
817
817
}
818
818
_ -> pure []
819
819
820
- genDocReportList notifyPrefs mp pkgDoc = do
821
- let addNotification uid m =
822
- if not (notifyOptOut npref) && notifyDocBuilderReport npref
823
- then Map. insertWith (++) uid [pkgDoc] m
824
- else m
825
- where npref = fromMaybe defaultNotifyPrefs (Map. lookup uid notifyPrefs)
826
- maintainers <- queryUserGroup $ maintainersGroup (packageName . pkgInfoId . fst $ pkgDoc)
827
- return $ foldr addNotification mp (toList maintainers)
820
+ genDocReportList notifyPrefs (pkg, success) = do
821
+ maintainers <- queryUserGroup $ maintainersGroup (packageName $ pkgInfoId pkg)
822
+ pure . flip mapMaybe (toList maintainers) $ \ uid ->
823
+ fmap (uid,) $ do
824
+ let NotifyPref {.. } = fromMaybe defaultNotifyPrefs (Map. lookup uid notifyPrefs)
825
+ guard $ not notifyOptOut
826
+ guard notifyDocBuilderReport
827
+ Just
828
+ NotifyDocsBuild
829
+ { notifyPackageId = pkgInfoId pkg
830
+ , notifyBuildSuccess = success
831
+ }
828
832
829
833
genTagProposalList notifyPrefs (pkg, (addedTags, deletedTags)) = do
830
834
maintainers <- queryUserGroup $ maintainersGroup pkg
@@ -849,13 +853,6 @@ userNotifyFeature serverEnv@ServerEnv{serverCron}
849
853
Map. toList . fmap toNotif
850
854
<$> getUserNotificationsOnRelease (queryUserGroup . maintainersGroup) idx revIdx queryGetUserNotifyPref pkg
851
855
852
- describeDocReport (pkg, success) =
853
- EmailContentParagraph $
854
- " Package doc build for " <> emailContentDisplay (packageName pkg) <> " :" <> EmailContentSoftBreak <>
855
- if success
856
- then " Build successful."
857
- else " Build failed."
858
-
859
856
sendNotifyEmailAndDelay :: Mail -> IO ()
860
857
sendNotifyEmailAndDelay email = do
861
858
-- TODO: if we need any configuration of sendmail stuff, has to go here
@@ -880,6 +877,10 @@ data Notification
880
877
, notifyReason :: Text
881
878
, notifyUpdatedAt :: UTCTime
882
879
}
880
+ | NotifyDocsBuild
881
+ { notifyPackageId :: PackageId
882
+ , notifyBuildSuccess :: Bool
883
+ }
883
884
| NotifyUpdateTags
884
885
{ notifyPackageName :: PackageName
885
886
, notifyAddedTags :: Set Tag
@@ -1012,6 +1013,11 @@ getNotificationEmails
1012
1013
notifyPackageName
1013
1014
notifyReason
1014
1015
notifyUpdatedAt
1016
+ NotifyDocsBuild {.. } ->
1017
+ generalNotification $
1018
+ renderNotifyDocsBuild
1019
+ notifyPackageId
1020
+ notifyBuildSuccess
1015
1021
NotifyUpdateTags {.. } ->
1016
1022
generalNotification $
1017
1023
renderNotifyUpdateTags
@@ -1052,6 +1058,13 @@ getNotificationEmails
1052
1058
, " Reason: " <> EmailContentText reason
1053
1059
]
1054
1060
1061
+ renderNotifyDocsBuild pkg success =
1062
+ EmailContentParagraph $
1063
+ " Package doc build for " <> renderPkgLink pkg <> " :" <> EmailContentSoftBreak
1064
+ <> if success
1065
+ then " Build successful."
1066
+ else " Build failed."
1067
+
1055
1068
renderNotifyUpdateTags pkg addedTags deletedTags =
1056
1069
EmailContentParagraph (" Pending tag proposal for " <> emailContentDisplay pkg <> " :" )
1057
1070
<> EmailContentList
0 commit comments