@@ -703,44 +703,14 @@ userNotifyFeature ServerEnv{serverBaseURI, serverCron}
703
703
genEmails =
704
704
dependencyReleaseEmails (queryUserGroup . maintainersGroup) idx revIdx queryGetUserNotifyPref
705
705
dependencyEmailMap <- Map. unionsWith (++) <$> traverse (genEmails . pkgInfoToPkgId) revisionsAndUploads
706
- let
707
- emailText :: MonadIO m => (UserId , PackageId ) -> [PackageId ] -> m [String ]
708
- emailText (uId, dep) revDeps = do
709
- mPrefs <- queryGetUserNotifyPref uId
710
- pure $
711
- case mPrefs of
712
- Nothing -> []
713
- Just NotifyPref {notifyDependencyTriggerBounds} ->
714
- [ " The dependency " <> display dep <> " has been updated."
715
- ] ++
716
- case notifyDependencyTriggerBounds of
717
- Always ->
718
- [ " You have requested to be notified for each upload/revision of a dependency. \
719
- \These are your packages that depend on " <> display dep <> " :"
720
- ]
721
- outOfRangeOption ->
722
- [ " You have requested to be notified when a dependency isn't accepted by any of \
723
- \your maintained packages."
724
- ] ++
725
- case outOfRangeOption of
726
- NewIncompatibility ->
727
- [ " The following packages did accept the second highest version of "
728
- <> display (packageName dep) <> " ."
729
- ]
730
- _ ->
731
- []
732
- ++
733
- [ " These are your packages that require " <> display (packageName dep) <> " but don't accept " <> display (packageVersion dep) <> " :"
734
- ]
735
- ++ map display revDeps
736
- dependencyEmailTextMaps <- Map. mapKeys fst <$> Map. traverseWithKey emailText dependencyEmailMap
706
+ dependencyEmails <- Map. mapKeys fst <$> Map. traverseWithKey describeDependencyUpdate dependencyEmailMap
737
707
738
708
-- Concat the constituent email parts such that only one email is sent per user
739
709
mapM_ (sendNotifyEmailAndDelay users) . Map. toList $ foldr1 (Map. unionWith (++) ) $ [revisionUploadEmails, groupActionEmails, docReportEmails, tagProposalEmails]
740
710
741
711
-- Dependency email notifications consist of multiple paragraphs, so it would be confusing if concatenated.
742
712
-- So they're sent independently.
743
- mapM_ (sendNotifyEmailAndDelay users) . Map. toList $ dependencyEmailTextMaps
713
+ mapM_ (sendNotifyEmailAndDelay users) . Map. toList $ dependencyEmails
744
714
745
715
updateState notifyState (SetNotifyTime now)
746
716
@@ -864,6 +834,35 @@ userNotifyFeature ServerEnv{serverBaseURI, serverCron}
864
834
where
865
835
showTags = intercalate " , " . map display . Set. toList
866
836
837
+ describeDependencyUpdate (uId, dep) revDeps = do
838
+ mPrefs <- queryGetUserNotifyPref uId
839
+ pure $
840
+ case mPrefs of
841
+ Nothing -> []
842
+ Just NotifyPref {notifyDependencyTriggerBounds} ->
843
+ [ " The dependency " <> display dep <> " has been updated."
844
+ ] ++
845
+ case notifyDependencyTriggerBounds of
846
+ Always ->
847
+ [ " You have requested to be notified for each upload/revision of a dependency. \
848
+ \These are your packages that depend on " <> display dep <> " :"
849
+ ]
850
+ outOfRangeOption ->
851
+ [ " You have requested to be notified when a dependency isn't accepted by any of \
852
+ \your maintained packages."
853
+ ] ++
854
+ case outOfRangeOption of
855
+ NewIncompatibility ->
856
+ [ " The following packages did accept the second highest version of "
857
+ <> display (packageName dep) <> " ."
858
+ ]
859
+ _ ->
860
+ []
861
+ ++
862
+ [ " These are your packages that require " <> display (packageName dep) <> " but don't accept " <> display (packageVersion dep) <> " :"
863
+ ]
864
+ ++ map display revDeps
865
+
867
866
sendNotifyEmailAndDelay :: Users. Users -> (UserId , [String ]) -> IO ()
868
867
sendNotifyEmailAndDelay users (uid, ebody) = do
869
868
mudetails <- queryUserDetails uid
0 commit comments