diff --git a/src/Handler/Admin/Avs.hs b/src/Handler/Admin/Avs.hs index 24c574276..3cb709b6f 100644 --- a/src/Handler/Admin/Avs.hs +++ b/src/Handler/Admin/Avs.hs @@ -325,7 +325,7 @@ postProblemAvsSynchR, getProblemAvsSynchR :: Handler Html postProblemAvsSynchR = getProblemAvsSynchR getProblemAvsSynchR = do let catchAllAvs' r = flip catch (\err -> addMessageModal Error (i18n MsgAvsCommunicationError) (Right (text2widget $ tshow (err :: SomeException))) >> redirect r) - catchAllAvs = catchAllAvs' ProblemAvsSynchR -- == current route; use only in conditions that are not repeated upon reload + catchAllAvs = catchAllAvs' ProblemAvsSynchR -- == current route; use only in conditions that are not repeated upon reload; do not call redirect within catchAllAvs actions! AvsLicenceDifferences{..} <- catchAllAvs' AdminR retrieveDifferingLicences -- @@ -340,8 +340,8 @@ getProblemAvsSynchR = do numUnknownLicenceOwners = length unknownLicenceOwners (btnImportUnknownWgt, btnImportUnknownRes) <- runButtonFormHash unknownLicenceOwners FIDBtnAvsImportUnknown - ifMaybeM btnImportUnknownRes () $ \BtnAvsImportUnknown -> catchAllAvs $ do - res <- forM (take 500 unknownLicenceOwners) $ try . upsertAvsUserById -- TODO: turn this into a background job + ifMaybeM btnImportUnknownRes () $ \BtnAvsImportUnknown -> do + res <- catchAllAvs $ forM (take 500 unknownLicenceOwners) $ try . upsertAvsUserById -- TODO: turn this into a background job let procRes (Right _) = (Sum 1, mempty :: Set.Set AvsPersonId, mempty :: Set.Set AvsPersonId, mempty) --TODO: continue here! --procRes (Left (AvsUserAmbiguous api)) = (Sum 0, Set.singleton api, mempty, mempty) @@ -371,10 +371,10 @@ getProblemAvsSynchR = do ^{revokeUnknownExecWgt} |] - ifMaybeM btnRevokeUnknownRes () $ \BtnAvsRevokeUnknown -> catchAllAvs $ do + ifMaybeM btnRevokeUnknownRes () $ \BtnAvsRevokeUnknown -> do let revokes = Set.map (AvsPersonLicence AvsNoLicence) $ Set.fromList unknownLicenceOwners no_revokes = Set.size revokes - oks <- setLicencesAvs revokes + oks <- catchAllAvs $ setLicencesAvs revokes if oks < no_revokes then addMessageI Error MsgRevokeUnknownLicencesFail else addMessageI Info MsgRevokeUnknownLicencesOk @@ -390,8 +390,8 @@ getProblemAvsSynchR = do now <- liftIO getCurrentTime let nowaday = utctDay now procRes :: AvsLicence -> (LicenceTableActionData, Set AvsPersonId) -> Handler () - procRes aLic (LicenceTableChangeAvsData , apids) = catchAllAvs $ do - oks <- setLicencesAvs $ Set.map (AvsPersonLicence aLic) apids -- catch here + procRes aLic (LicenceTableChangeAvsData , apids) = do + oks <- catchAllAvs $ setLicencesAvs $ Set.map (AvsPersonLicence aLic) apids let no_req = Set.size apids mkind = if oks < no_req then Warning else Success addMessageI mkind $ MsgAvsSetLicences aLic oks no_req