@@ -699,8 +699,7 @@ userNotifyFeature serverEnv@ServerEnv{serverBaseURI, serverCron}
699
699
let docReportEmails = foldMap describeDocReport <$> docReportNotifications
700
700
701
701
tagProposals <- collectTagProposals
702
- tagProposalNotifications <- foldM (genTagProposalList notifyPrefs) Map. empty tagProposals
703
- let tagProposalEmails = foldMap describeTagProposal <$> tagProposalNotifications
702
+ tagProposalNotifications <- concatMapM (genTagProposalList notifyPrefs) tagProposals
704
703
705
704
idx <- queryGetPackageIndex
706
705
revIdx <- liftIO queryReverseIndex
@@ -711,13 +710,13 @@ userNotifyFeature serverEnv@ServerEnv{serverBaseURI, serverCron}
711
710
getNotificationEmails serverEnv userDetailsFeature users
712
711
( foldr1 (Map. unionWith (<>) )
713
712
[ docReportEmails
714
- , tagProposalEmails
715
713
]
716
714
, dependencyEmails
717
715
) $
718
716
concat
719
717
[ revisionUploadNotifications
720
718
, groupActionNotifications
719
+ , tagProposalNotifications
721
720
]
722
721
mapM_ sendNotifyEmailAndDelay emails
723
722
@@ -834,14 +833,19 @@ userNotifyFeature serverEnv@ServerEnv{serverBaseURI, serverCron}
834
833
maintainers <- queryUserGroup $ maintainersGroup (packageName . pkgInfoId . fst $ pkgDoc)
835
834
return $ foldr addNotification mp (toList maintainers)
836
835
837
- genTagProposalList notifyPrefs mp pkgTags = do
838
- let addNotification uid m =
839
- if not (notifyOptOut npref) && notifyPendingTags npref
840
- then Map. insertWith (++) uid [pkgTags] m
841
- else m
842
- where npref = fromMaybe defaultNotifyPrefs (Map. lookup uid notifyPrefs)
843
- maintainers <- queryUserGroup $ maintainersGroup (fst pkgTags)
844
- return $ foldr addNotification mp (toList maintainers)
836
+ genTagProposalList notifyPrefs (pkg, (addedTags, deletedTags)) = do
837
+ maintainers <- queryUserGroup $ maintainersGroup pkg
838
+ pure . flip mapMaybe (toList maintainers) $ \ uid ->
839
+ fmap (uid,) $ do
840
+ let NotifyPref {.. } = fromMaybe defaultNotifyPrefs (Map. lookup uid notifyPrefs)
841
+ guard $ not notifyOptOut
842
+ guard notifyPendingTags
843
+ Just
844
+ NotifyUpdateTags
845
+ { notifyPackageName = pkg
846
+ , notifyAddedTags = addedTags
847
+ , notifyDeletedTags = deletedTags
848
+ }
845
849
846
850
genDependencyUpdateList idx revIdx pid =
847
851
Map. mapKeys (, pid) <$>
@@ -854,15 +858,6 @@ userNotifyFeature serverEnv@ServerEnv{serverBaseURI, serverCron}
854
858
then " Build successful."
855
859
else " Build failed."
856
860
857
- describeTagProposal (pkgName, (addTags, delTags)) =
858
- EmailContentParagraph (" Pending tag proposal for " <> emailContentDisplay pkgName <> " :" )
859
- <> EmailContentList
860
- [ " Additions: " <> showTags addTags
861
- , " Deletions: " <> showTags delTags
862
- ]
863
- where
864
- showTags = emailContentIntercalate " , " . map emailContentDisplay . Set. toList
865
-
866
861
describeDependencyUpdate (uId, dep) revDeps = do
867
862
mPrefs <- queryGetUserNotifyPref uId
868
863
pure $
@@ -918,6 +913,11 @@ data Notification
918
913
, notifyReason :: Text
919
914
, notifyUpdatedAt :: UTCTime
920
915
}
916
+ | NotifyUpdateTags
917
+ { notifyPackageName :: PackageName
918
+ , notifyAddedTags :: Set Tag
919
+ , notifyDeletedTags :: Set Tag
920
+ }
921
921
922
922
data NotifyMaintainerUpdateType = MaintainerAdded | MaintainerRemoved
923
923
@@ -1036,6 +1036,12 @@ getNotificationEmails
1036
1036
notifyPackageName
1037
1037
notifyReason
1038
1038
notifyUpdatedAt
1039
+ NotifyUpdateTags {.. } ->
1040
+ generalNotification $
1041
+ renderNotifyUpdateTags
1042
+ notifyPackageName
1043
+ notifyAddedTags
1044
+ notifyDeletedTags
1039
1045
where
1040
1046
generalNotification emailContent = Just (emailContent, GeneralNotification )
1041
1047
@@ -1059,6 +1065,14 @@ getNotificationEmails
1059
1065
, " Reason: " <> EmailContentText reason
1060
1066
]
1061
1067
1068
+ renderNotifyUpdateTags pkg addedTags deletedTags =
1069
+ EmailContentParagraph (" Pending tag proposal for " <> emailContentDisplay pkg <> " :" )
1070
+ <> EmailContentList
1071
+ [ " Additions: " <> showTags addedTags
1072
+ , " Deletions: " <> showTags deletedTags
1073
+ ]
1074
+ where
1075
+ showTags = emailContentIntercalate " , " . map emailContentDisplay . Set. toList
1062
1076
1063
1077
{- ---- Rendering helpers -----}
1064
1078
0 commit comments