diff --git a/messages/uniworx/categories/settings/de-de-formal.msg b/messages/uniworx/categories/settings/de-de-formal.msg index cbe000727..1267b8c44 100644 --- a/messages/uniworx/categories/settings/de-de-formal.msg +++ b/messages/uniworx/categories/settings/de-de-formal.msg @@ -41,6 +41,7 @@ PostAddress: Postalische Adresse PostAddressTip: Mindestens eine Zeile mit Straße und Hausnummer und eine Zeile mit Postleitzahl und Ort. Kein Empfängername, denn dieser wird später automatisch hinzugefügt. UserPostalInvalid: Postadresse muss mindestens eine Zeile mit Straße und Hausnummer und eine separate Zeile mit Postleitzahl und Ort enthalten! UserPrefersPostalInvalid: Entweder postalische Benachrichtigungen deaktivieren oder eine Postadresse angeben! +UserPostLastUpdate: Postadresse zuletzt geändert FormNotifications: Benachrichtigungen diff --git a/messages/uniworx/categories/settings/en-eu.msg b/messages/uniworx/categories/settings/en-eu.msg index 4e3d7af29..a8ddfdfad 100644 --- a/messages/uniworx/categories/settings/en-eu.msg +++ b/messages/uniworx/categories/settings/en-eu.msg @@ -41,6 +41,7 @@ PostAddress: Postal address PostAddressTip: Should contain at least one line with street and house number and another line featuring zip code and town. Omit a recipient name, since it will be added later. UserPostalInvalid: Postal address must have at least one line with street and house number and another with zip code and town! UserPrefersPostalInvalid: Either deactivate postal notification or supply a valid postal address! +UserPostLastUpdate: Last postal address change FormNotifications: Notifications diff --git a/models/users.model b/models/users.model index 5f15d937d..40ae1bee2 100644 --- a/models/users.model +++ b/models/users.model @@ -46,6 +46,7 @@ User json -- Each Uni2work user has a corresponding row in this table; create companyDepartment Text Maybe -- thus we store such information for ease of reference directly, if available pinPassword Text Maybe -- used to encrypt pins within emails postAddress StoredMarkup Maybe + postLastUpdate UTCTime Maybe -- record postal address updates prefersPostal Bool default=false -- user prefers letters by post instead of email examOfficeGetSynced Bool default=true -- whether synced status should be displayed for exam results by default examOfficeGetLabels Bool default=true -- whether labels should be displayed for exam results by default diff --git a/src/Foundation/Yesod/Auth.hs b/src/Foundation/Yesod/Auth.hs index 3044f385c..c43da2b16 100644 --- a/src/Foundation/Yesod/Auth.hs +++ b/src/Foundation/Yesod/Auth.hs @@ -291,6 +291,7 @@ decodeUser now UserDefaultConf{..} upsertMode ldapData = do , userDisplayEmail = userEmail , userMatrikelnummer = Nothing -- not known from LDAP, must be derived from REST interface to AVS TODO , userPostAddress = Nothing -- not known from LDAP, must be derived from REST interface to AVS TODO + , userPostLastUpdate = Nothing , userPinPassword = Nothing -- must be derived via AVS , userPrefersPostal = userDefaultPrefersPostal , .. diff --git a/src/Handler/LMS/Fake.hs b/src/Handler/LMS/Fake.hs index b884e4fbf..c3693e544 100644 --- a/src/Handler/LMS/Fake.hs +++ b/src/Handler/LMS/Fake.hs @@ -112,6 +112,7 @@ fakeQualificationUsers (Entity qid Qualification{qualificationRefreshWithin}) (u userCompanyPersonalNumber = Nothing userCompanyDepartment = Nothing userPostAddress = postalAddress + userPostLastUpdate = Nothing userPinPassword = Just "tomatenmarmelade" in User{..} diff --git a/src/Handler/Profile.hs b/src/Handler/Profile.hs index f5dfeb2da..434aaea24 100644 --- a/src/Handler/Profile.hs +++ b/src/Handler/Profile.hs @@ -441,8 +441,11 @@ serveProfileR (uid, user@User{..}) = do ((res,formWidget), formEnctype) <- runFormPost . validateForm (validateSettings user) . identifyForm ProfileSettings $ makeSettingForm settingsTemplate formResult res $ \SettingsForm{..} -> do + now <- liftIO getCurrentTime runDBJobs $ do update uid $ + [ UserDisplayEmail =. stgDisplayEmail | userDisplayEmail == stgDisplayEmail ] ++ -- SJ asks: what does this line achieve? + [ UserPostLastUpdate =. Just now | userPostAddress /= stgPostAddress ] ++ [ UserDisplayName =. stgDisplayName , UserMaxFavourites =. stgMaxFavourites , UserMaxFavouriteTerms =. stgMaxFavouriteTerms @@ -459,7 +462,7 @@ serveProfileR (uid, user@User{..}) = do , UserPrefersPostal =. stgPrefersPostal , UserExamOfficeGetSynced =. (stgExamOfficeSettings & eosettingsGetSynced) , UserExamOfficeGetLabels =. (stgExamOfficeSettings & eosettingsGetLabels) - ] ++ [ UserDisplayEmail =. stgDisplayEmail | userDisplayEmail == stgDisplayEmail ] + ] updateFavourites Nothing when (stgDisplayEmail /= userDisplayEmail) $ do queueDBJob $ JobChangeUserDisplayEmail uid stgDisplayEmail diff --git a/src/Handler/Utils/Avs.hs b/src/Handler/Utils/Avs.hs index 9b38653d9..f65841970 100644 --- a/src/Handler/Utils/Avs.hs +++ b/src/Handler/Utils/Avs.hs @@ -443,7 +443,9 @@ upsertAvsUserById api = do oldCards <- selectList [UserAvsCardPersonId ==. api] [] let oldAddrs = Set.fromList $ mapMaybe (maybeCompanyAddress . userAvsCardCard . entityVal) oldCards unless (maybe True (`Set.member` oldAddrs) mbCoFirmAddr) $ do -- update postal address, unless the exact address had been seen before - updateWhere [UserId ==. uid] [UserPostAddress =. userFirmAddr] + encRecipient :: CryptoUUIDUser <- encrypt uid + $logInfoS "AVS" $ "Postal address updated for" <> tshow encRecipient + updateWhere [UserId ==. uid] [UserPostAddress =. userFirmAddr, UserPostLastUpdate =. Just now] whenIsJust pinCard $ \pCard -> -- update pin, but only if it was unset or set to the value of an old card unlessM (exists [UserAvsCardCardNo ==. getFullCardNo pCard]) $ do let oldPins = Just . personCard2pin . userAvsCardCard . entityVal <$> oldCards diff --git a/src/Utils/Users.hs b/src/Utils/Users.hs index 5c83567e7..36721dd7c 100644 --- a/src/Utils/Users.hs +++ b/src/Utils/Users.hs @@ -92,6 +92,7 @@ addNewUser AddUserData{..} = do , userCompanyPersonalNumber = audFPersonalNumber , userCompanyDepartment = audFDepartment , userPostAddress = audPostAddress + , userPostLastUpdate = Nothing , userPrefersPostal = audPrefersPostal , userPinPassword = audPinPassword , userMatrikelnummer = audMatriculation diff --git a/templates/profileData.hamlet b/templates/profileData.hamlet index 39d17144a..8c7644808 100644 --- a/templates/profileData.hamlet +++ b/templates/profileData.hamlet @@ -48,6 +48,11 @@ $# SPDX-License-Identifier: AGPL-3.0-or-later _{MsgAdminUserPostAddress}