chore(avs): display last avs synch error to admins on profile
This commit is contained in:
parent
7e7bd993a1
commit
31814b1400
@ -94,6 +94,7 @@ ProfileNever: Nie
|
|||||||
ProfileLdapPrimaryKey: LDAP-Primärschlüssel
|
ProfileLdapPrimaryKey: LDAP-Primärschlüssel
|
||||||
ProfileLastLdapSynchronisation: Letzte LDAP-Synchronisation
|
ProfileLastLdapSynchronisation: Letzte LDAP-Synchronisation
|
||||||
ProfileLastAvsSynchronisation: Letzte AVS-Synchronisation
|
ProfileLastAvsSynchronisation: Letzte AVS-Synchronisation
|
||||||
|
ProfileLastAvsSynchError: Letzte AVS-Fehlermeldung
|
||||||
|
|
||||||
NotificationSettingsUpdate: Benachrichtigungs-Einstellungen erfolgreich gespeichert
|
NotificationSettingsUpdate: Benachrichtigungs-Einstellungen erfolgreich gespeichert
|
||||||
NotificationSettingsHeading displayName@Text: Benachrichtigungs-Einstellungen für #{displayName}
|
NotificationSettingsHeading displayName@Text: Benachrichtigungs-Einstellungen für #{displayName}
|
||||||
|
|||||||
@ -94,6 +94,7 @@ ProfileNever: Never
|
|||||||
ProfileLdapPrimaryKey: LDAP primary key
|
ProfileLdapPrimaryKey: LDAP primary key
|
||||||
ProfileLastLdapSynchronisation: Last LDAP synchronisation
|
ProfileLastLdapSynchronisation: Last LDAP synchronisation
|
||||||
ProfileLastAvsSynchronisation: Last AVS synchronisation
|
ProfileLastAvsSynchronisation: Last AVS synchronisation
|
||||||
|
ProfileLastAvsSynchError: Last AVS Error
|
||||||
|
|
||||||
NotificationSettingsUpdate: Successfully updated notification settings
|
NotificationSettingsUpdate: Successfully updated notification settings
|
||||||
NotificationSettingsHeading displayName: Notification settings for #{displayName}
|
NotificationSettingsHeading displayName: Notification settings for #{displayName}
|
||||||
|
|||||||
@ -18,6 +18,7 @@ UserAvs
|
|||||||
user UserId
|
user UserId
|
||||||
noPerson Int default=0 -- only needed for manual communication with personnel from Ausweisverwaltungsstelle
|
noPerson Int default=0 -- only needed for manual communication with personnel from Ausweisverwaltungsstelle
|
||||||
lastSynch UTCTime default=now()
|
lastSynch UTCTime default=now()
|
||||||
|
lastSynchError Text Maybe
|
||||||
UniqueUserAvsUser user
|
UniqueUserAvsUser user
|
||||||
UniqueUserAvsId personId
|
UniqueUserAvsId personId
|
||||||
deriving Generic Show
|
deriving Generic Show
|
||||||
|
|||||||
@ -418,19 +418,19 @@ upsertAvsUserById api = do
|
|||||||
$logInfoS "AVS" $ "Creating new user with avsInternalPersonalNo " <> tshow persNo
|
$logInfoS "AVS" $ "Creating new user with avsInternalPersonalNo " <> tshow persNo
|
||||||
candidates <- selectKeysList [UserCompanyPersonalNumber ==. Just persNo] []
|
candidates <- selectKeysList [UserCompanyPersonalNumber ==. Just persNo] []
|
||||||
case candidates of
|
case candidates of
|
||||||
[uid] -> $logInfoS "AVS" "Matching user found, linking." >> insertUniqueEntity (UserAvs api uid avsPersonPersonNo now)
|
[uid] -> $logInfoS "AVS" "Matching user found, linking." >> insertUniqueEntity (UserAvs api uid avsPersonPersonNo now Nothing)
|
||||||
(_:_) -> throwM $ AvsUserAmbiguous api
|
(_:_) -> throwM $ AvsUserAmbiguous api
|
||||||
[] -> do
|
[] -> do
|
||||||
upsRes :: Either SomeException (Entity User)
|
upsRes :: Either SomeException (Entity User)
|
||||||
<- try $ ldapLookupAndUpsert persNo
|
<- try $ ldapLookupAndUpsert persNo
|
||||||
$logInfoS "AVS" $ "No matching existing user found. Attempted LDAP upsert returned: " <> tshow upsRes
|
$logInfoS "AVS" $ "No matching existing user found. Attempted LDAP upsert returned: " <> tshow upsRes
|
||||||
case upsRes of
|
case upsRes of
|
||||||
Right Entity{entityKey=uid} -> insertUniqueEntity $ UserAvs api uid avsPersonPersonNo now -- pin/addr are updated in next step anyway
|
Right Entity{entityKey=uid} -> insertUniqueEntity $ UserAvs api uid avsPersonPersonNo now Nothing -- pin/addr are updated in next step anyway
|
||||||
Left err -> do
|
Left err -> do
|
||||||
$logWarnS "AVS" $ "AVS user with avsInternalPersonalNo " <> tshow persNo <> " not found in LDAP: " <> tshow err
|
$logWarnS "AVS" $ "AVS user with avsInternalPersonalNo " <> tshow persNo <> " not found in LDAP: " <> tshow err
|
||||||
return mbuid -- == Nothing -- user could not be created somehow
|
return mbuid -- == Nothing -- user could not be created somehow
|
||||||
(Just Entity{ entityKey = uaid }, _) -> do
|
(Just Entity{ entityKey = uaid }, _) -> do
|
||||||
update uaid [ UserAvsLastSynch =. now ] -- mark as updated early, to prevent failed users to clog the synch
|
update uaid [ UserAvsLastSynch =. now, UserAvsLastSynchError =. Nothing ] -- mark as updated early, to prevent failed users to clog the synch
|
||||||
return mbuid
|
return mbuid
|
||||||
_other -> return mbuid
|
_other -> return mbuid
|
||||||
$logInfoS "AVS" $ "upsert prestep result: " <> tshow mbuid <> " --- " <> tshow mbapd
|
$logInfoS "AVS" $ "upsert prestep result: " <> tshow mbuid <> " --- " <> tshow mbapd
|
||||||
@ -465,7 +465,7 @@ upsertAvsUserById api = do
|
|||||||
}
|
}
|
||||||
mbUid <- addNewUser newUsr -- triggers JobSynchroniseLdapUser, JobSendPasswordReset and NotificationUserAutoModeUpdate -- TODO: check if these are failsafe
|
mbUid <- addNewUser newUsr -- triggers JobSynchroniseLdapUser, JobSendPasswordReset and NotificationUserAutoModeUpdate -- TODO: check if these are failsafe
|
||||||
whenIsJust mbUid $ \uid -> runDB $ do
|
whenIsJust mbUid $ \uid -> runDB $ do
|
||||||
insert_ $ UserAvs avsPersonPersonID uid avsPersonPersonNo now
|
insert_ $ UserAvs avsPersonPersonID uid avsPersonPersonNo now Nothing
|
||||||
forM_ avsPersonPersonCards $ -- save all cards for later comparisons whether an update occurred
|
forM_ avsPersonPersonCards $ -- save all cards for later comparisons whether an update occurred
|
||||||
-- let cs :: Set AvsDataPersonCard = Set.fromList $ catMaybes [pinCard, addrCard]
|
-- let cs :: Set AvsDataPersonCard = Set.fromList $ catMaybes [pinCard, addrCard]
|
||||||
-- forM_ cs $ -- only save used cards for the postal address update detection
|
-- forM_ cs $ -- only save used cards for the postal address update detection
|
||||||
|
|||||||
@ -37,17 +37,23 @@ dispatchJobSynchroniseAvs numIterations epoch iteration pause
|
|||||||
|
|
||||||
workJobSynchroniseAvs :: Either AvsPersonId UserId -> Maybe UTCTime -> JobHandler UniWorX
|
workJobSynchroniseAvs :: Either AvsPersonId UserId -> Maybe UTCTime -> JobHandler UniWorX
|
||||||
workJobSynchroniseAvs eauid pause = JobHandlerException $ do
|
workJobSynchroniseAvs eauid pause = JobHandlerException $ do
|
||||||
let uniqKey = either UniqueUserAvsId UniqueUserAvsUser eauid
|
let uniqKey = either UniqueUserAvsId UniqueUserAvsUser eauid
|
||||||
runDB (getBy uniqKey) >>= \case
|
runDB (getBy uniqKey) >>= \case
|
||||||
Nothing -> return () -- do not create new newers in this background job, only update existing
|
Nothing -> return () -- do not create new newers in this background job, only update existing
|
||||||
Just Entity{entityVal=UserAvs{..}}
|
Just Entity{entityKey=avsKey, entityVal=UserAvs{..} }
|
||||||
| maybe False (userAvsLastSynch >=) pause -> return () -- we just updated this one within the given limit
|
| maybe False (userAvsLastSynch >=) pause -> return () -- we just updated this one within the given limit
|
||||||
| otherwise -> catch (void $ upsertAvsUserById userAvsPersonId) -- updates UserAvsLastSynch
|
| otherwise -> catch (void $ upsertAvsUserById userAvsPersonId) -- already updates UserAvsLastSynch
|
||||||
(\case
|
(\exc -> do
|
||||||
AvsInterfaceUnavailable -> return () -- ignore and retry later
|
now <- liftIO getCurrentTime
|
||||||
AvsUserUnknownByAvs _ -> return () -- ignore for users no longer listed in AVS
|
let excMsg = tshow exc <> " at " <> tshow now
|
||||||
otherExc -> throwM otherExc
|
runDB (update avsKey [UserAvsLastSynchError =. Just excMsg])
|
||||||
)
|
case exc of
|
||||||
|
AvsInterfaceUnavailable -> return () -- ignore and retry later
|
||||||
|
AvsUserUnknownByAvs _ -> return () -- ignore for users no longer listed in AVS
|
||||||
|
otherExc -> throwM otherExc
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
dispatchJobSynchroniseAvsId :: AvsPersonId -> Maybe UTCTime -> JobHandler UniWorX
|
dispatchJobSynchroniseAvsId :: AvsPersonId -> Maybe UTCTime -> JobHandler UniWorX
|
||||||
dispatchJobSynchroniseAvsId = workJobSynchroniseAvs . Left
|
dispatchJobSynchroniseAvsId = workJobSynchroniseAvs . Left
|
||||||
|
|||||||
@ -20,6 +20,11 @@ $# SPDX-License-Identifier: AGPL-3.0-or-later
|
|||||||
^{messageTooltip tooltipAvsPersNo}
|
^{messageTooltip tooltipAvsPersNo}
|
||||||
<dd .deflist__dd .ldap-primary-key>
|
<dd .deflist__dd .ldap-primary-key>
|
||||||
#{view _userAvsNoPerson avs}
|
#{view _userAvsNoPerson avs}
|
||||||
|
$maybe avsError <- view _userAvsLastSynchError avs
|
||||||
|
<dt .deflist__dt>
|
||||||
|
_{MsgProfileLastAvsSynchError}
|
||||||
|
<dd .deflist__dd>
|
||||||
|
#{avsError}
|
||||||
<dt .deflist__dt>
|
<dt .deflist__dt>
|
||||||
_{MsgProfileLastAvsSynchronisation}
|
_{MsgProfileLastAvsSynchronisation}
|
||||||
<dd .deflist__dd>
|
<dd .deflist__dd>
|
||||||
|
|||||||
@ -575,7 +575,7 @@ fillDb = do
|
|||||||
matrikel <- toMatrikel <$> getRandomRs (0 :: Int, 9 :: Int)
|
matrikel <- toMatrikel <$> getRandomRs (0 :: Int, 9 :: Int)
|
||||||
manyUsers <- insertMany . getZipList $ manyUser <$> ZipList ((,,) <$> firstNames <*> middlenames <*> surnames) <*> ZipList matrikel
|
manyUsers <- insertMany . getZipList $ manyUser <$> ZipList ((,,) <$> firstNames <*> middlenames <*> surnames) <*> ZipList matrikel
|
||||||
matUsers <- selectList [UserMatrikelnummer !=. Nothing] []
|
matUsers <- selectList [UserMatrikelnummer !=. Nothing] []
|
||||||
insertMany_ [UserAvs (AvsPersonId n) uid n now | Entity uid User{userMatrikelnummer = fmap readMay -> Just (Just n)} <- matUsers]
|
insertMany_ [UserAvs (AvsPersonId n) uid n now Nothing | Entity uid User{userMatrikelnummer = fmap readMay -> Just (Just n)} <- matUsers]
|
||||||
|
|
||||||
let tmin = -1
|
let tmin = -1
|
||||||
tmax = 2
|
tmax = 2
|
||||||
@ -681,12 +681,12 @@ fillDb = do
|
|||||||
void . insert' $ UserSchool uid mi False
|
void . insert' $ UserSchool uid mi False
|
||||||
for_ [jost] $ \uid ->
|
for_ [jost] $ \uid ->
|
||||||
void . insert' $ UserSchool uid avn False
|
void . insert' $ UserSchool uid avn False
|
||||||
void . insert' $ UserAvs (AvsPersonId 12345678) jost 87654321 (n_day' $ -12)
|
void . insert' $ UserAvs (AvsPersonId 12345678) jost 87654321 (n_day' $ -12) (Just "Some Message here")
|
||||||
void . insert' $ UserAvs (AvsPersonId 2) svaupel 2 (n_day' $ -22)
|
void . insert' $ UserAvs (AvsPersonId 2) svaupel 2 (n_day' $ -22) Nothing
|
||||||
void . insert' $ UserAvs (AvsPersonId 3) gkleen 3 (n_day' $ -32)
|
void . insert' $ UserAvs (AvsPersonId 3) gkleen 3 (n_day' $ -32) Nothing
|
||||||
void . insert' $ UserAvs (AvsPersonId 4) sbarth 4 now
|
void . insert' $ UserAvs (AvsPersonId 4) sbarth 4 now Nothing
|
||||||
void . insert' $ UserAvs (AvsPersonId 5) fhamann 5 now
|
void . insert' $ UserAvs (AvsPersonId 5) fhamann 5 now (Just "another message from avs synch")
|
||||||
void . insert' $ UserAvs (AvsPersonId 77) tinaTester 77 now
|
void . insert' $ UserAvs (AvsPersonId 77) tinaTester 77 now Nothing
|
||||||
insert_ $ UserAvsCard (AvsPersonId 12345678) (AvsFullCardNo (AvsCardNo "1234") "4") (AvsDataPersonCard True Nothing Nothing AvsCardColorGelb (Set.fromList ['F']) Nothing Nothing Nothing Nothing (AvsCardNo "1234") "4") now
|
insert_ $ UserAvsCard (AvsPersonId 12345678) (AvsFullCardNo (AvsCardNo "1234") "4") (AvsDataPersonCard True Nothing Nothing AvsCardColorGelb (Set.fromList ['F']) Nothing Nothing Nothing Nothing (AvsCardNo "1234") "4") now
|
||||||
insert_ $ UserAvsCard (AvsPersonId 2) (AvsFullCardNo (AvsCardNo "3344") "1") (AvsDataPersonCard True Nothing Nothing AvsCardColorRot (Set.fromList ['F','R']) Nothing Nothing Nothing Nothing (AvsCardNo "3344") "1") now
|
insert_ $ UserAvsCard (AvsPersonId 2) (AvsFullCardNo (AvsCardNo "3344") "1") (AvsDataPersonCard True Nothing Nothing AvsCardColorRot (Set.fromList ['F','R']) Nothing Nothing Nothing Nothing (AvsCardNo "3344") "1") now
|
||||||
insert_ $ UserAvsCard (AvsPersonId 3) (AvsFullCardNo (AvsCardNo "7788") "1") (AvsDataPersonCard False Nothing Nothing AvsCardColorRot (Set.fromList ['F','R']) Nothing Nothing Nothing Nothing (AvsCardNo "7788") "1") now
|
insert_ $ UserAvsCard (AvsPersonId 3) (AvsFullCardNo (AvsCardNo "7788") "1") (AvsDataPersonCard False Nothing Nothing AvsCardColorRot (Set.fromList ['F','R']) Nothing Nothing Nothing Nothing (AvsCardNo "7788") "1") now
|
||||||
|
|||||||
Reference in New Issue
Block a user