fix(email): avoid sending to invalid email address

This commit is contained in:
Steffen Jost 2023-02-07 18:31:35 +01:00
parent 006ab632a3
commit 71ccac0dfe

View File

@ -15,6 +15,7 @@ import Jobs.Queue
import qualified Data.Set as Set
import Handler.Utils.Profile (validEmail')
import Handler.Utils.ExamOffice.Exam
import Handler.Utils.ExamOffice.ExternalExam
@ -25,7 +26,9 @@ dispatchJobQueueNotification :: Notification -> JobHandler UniWorX
dispatchJobQueueNotification jNotification = JobHandlerAtomic $
runConduit $ yield jNotification
.| transPipe (hoist lift) determineNotificationCandidates
.| C.filterM (\(notification', override, Entity _ User{userNotificationSettings}) -> or2M (return override) $ notificationAllowed userNotificationSettings <$> hoist lift (classifyNotification notification'))
.| C.filterM (\(notification', override, Entity _ User{userNotificationSettings,userEmail}) ->
and2M (return $ validEmail' userEmail) $
or2M (return override) $ notificationAllowed userNotificationSettings <$> hoist lift (classifyNotification notification'))
.| C.map (\(notification', _, Entity uid _) -> JobSendNotification uid notification')
.| sinkDBJobs