From 184ccbc7a60f8a3baded3f30eabeb6649ffd331b Mon Sep 17 00:00:00 2001 From: Steffen Jost Date: Thu, 13 Oct 2022 16:24:26 +0200 Subject: [PATCH] chore(notifications): send notifications to supervisors, but it wont work --- src/Jobs/Handler/SendNotification.hs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Jobs/Handler/SendNotification.hs b/src/Jobs/Handler/SendNotification.hs index 4b31fcafa..80574a065 100644 --- a/src/Jobs/Handler/SendNotification.hs +++ b/src/Jobs/Handler/SendNotification.hs @@ -24,5 +24,11 @@ import Jobs.Handler.SendNotification.Qualification dispatchJobSendNotification :: UserId -> Notification -> JobHandler UniWorX -dispatchJobSendNotification jRecipient jNotification = JobHandlerException $ - $(dispatchTH ''Notification) jNotification jRecipient +dispatchJobSendNotification jRecipient jNotification = JobHandlerException $ do + -- TODO: this is a bad idea, since all notifications use jRecipient to generate the message body, + -- thus supervisors would receive all notifications with their own name inside! + superVs <- runDB $ selectList [UserSupervisorUser ==. jRecipient, UserSupervisorRerouteNotifications ==. True] [] + if null superVs + then $(dispatchTH ''Notification) jNotification jRecipient + else forM_ superVs $ \Entity { entityVal = UserSupervisor { userSupervisorSupervisor = svr } } -> + $(dispatchTH ''Notification) jNotification svr