From 227970e4b1caa59ea472e65008318ae0f891252d Mon Sep 17 00:00:00 2001 From: Steffen Jost Date: Wed, 7 Sep 2022 17:59:44 +0200 Subject: [PATCH] refacor(lms): log messages no longer track unencrypted userID --- .../Handler/SendNotification/Qualification.hs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/Jobs/Handler/SendNotification/Qualification.hs b/src/Jobs/Handler/SendNotification/Qualification.hs index 8642f3b06..52334c689 100644 --- a/src/Jobs/Handler/SendNotification/Qualification.hs +++ b/src/Jobs/Handler/SendNotification/Qualification.hs @@ -30,12 +30,13 @@ dispatchNotificationQualificationExpiry nQualification _nExpiry jRecipient = use <$> getJust jRecipient <*> getJust nQualification <*> getJustBy (UniqueQualificationUser nQualification jRecipient) - + + encRecipient :: CryptoUUIDUser <- liftHandler $ encrypt jRecipient let entRecipient = Entity jRecipient recipient qname = CI.original qualificationName expiryDate <- formatTimeUser SelFormatDate qualificationUserValidUntil $ Just entRecipient - - $logDebugS "LMS" $ "Notify " <> tshow jRecipient <> " about expiry of qualification " <> qname + + $logDebugS "LMS" $ "Notify " <> tshow encRecipient <> " about expiry of qualification " <> qname replaceMailHeader "Auto-Submitted" $ Just "auto-generated" setSubjectI $ MsgMailSubjectQualificationExpiry qname @@ -53,10 +54,12 @@ dispatchNotificationQualificationRenewal nQualification jRecipient = do <*> getJust nQualification <*> getJustBy (UniqueQualificationUser nQualification jRecipient) <*> getJustBy (UniqueLmsQualificationUser nQualification jRecipient) + + encRecipient :: CryptoUUIDUser <- encrypt jRecipient let entRecipient = Entity jRecipient recipient qname = CI.original qualificationName - $logDebugS "LMS" $ "Notify " <> tshow jRecipient <> " for renewal of qualification " <> qname + $logDebugS "LMS" $ "Notify " <> tshow encRecipient <> " for renewal of qualification " <> qname now <- liftIO getCurrentTime letterDate <- formatTimeUser SelFormatDate now $ Just entRecipient @@ -76,7 +79,7 @@ dispatchNotificationQualificationRenewal nQualification jRecipient = do ] pdfRenewal pdfMeta >>= \case Left err -> do - let msg = "Notify " <> tshow jRecipient <> " PDF generation failed with error: " <> err + let msg = "Notify " <> tshow encRecipient <> " PDF generation failed with error: " <> err $logErrorS "LMS" msg error $ unpack msg @@ -84,7 +87,7 @@ dispatchNotificationQualificationRenewal nQualification jRecipient = do let printSender = Nothing runDB (sendLetter printJobName pdf printSender (Just jRecipient) Nothing (Just nQualification)) >>= \case Left err -> do - let msg = "Notify " <> tshow jRecipient <> " PDF printing to send letter failed with error: " <> err + let msg = "Notify " <> tshow encRecipient <> " PDF printing to send letter failed with error: " <> err $logErrorS "LMS" msg error $ unpack msg Right (msg,_) @@ -93,7 +96,7 @@ dispatchNotificationQualificationRenewal nQualification jRecipient = do Right pdf -> userMailT jRecipient $ do -- userPrefersLetter is false if both userEmail and userPostAddress are null - when (Text.null (CI.original userEmail)) $ $logErrorS "LMS" ("Notify " <> tshow jRecipient <> " failed: no email nor address for user known!") + when (Text.null (CI.original userEmail)) $ $logErrorS "LMS" ("Notify " <> tshow encRecipient <> " failed: no email nor address for user known!") replaceMailHeader "Auto-Submitted" $ Just "auto-generated" setSubjectI $ MsgMailSubjectQualificationRenewal qname @@ -102,7 +105,7 @@ dispatchNotificationQualificationRenewal nQualification jRecipient = do encryptPDF (fromMaybe "tomatenmarmelade" userPinPassword) pdf >>= \case -- TODO Left err -> do - let msg = "Notify " <> tshow jRecipient <> " PDF encryption failed with error: " <> err + let msg = "Notify " <> tshow encRecipient <> " PDF encryption failed with error: " <> err $logErrorS "LMS" msg Right pdffile -> do