fix(avs): updateReceivers should not re-insert formerly known receivers
This commit is contained in:
parent
274cd21e79
commit
434549c945
@ -177,7 +177,7 @@ updateReceivers :: UserId -> Handler (Entity User, [Entity User], Bool)
|
|||||||
updateReceivers uid = do
|
updateReceivers uid = do
|
||||||
-- First perform AVS update for receiver
|
-- First perform AVS update for receiver
|
||||||
runDBRead (getBy (UniqueUserAvsUser uid)) >>= \case
|
runDBRead (getBy (UniqueUserAvsUser uid)) >>= \case
|
||||||
Just Entity{entityVal=UserAvs{userAvsPersonId = apid}} -> catchAll2log $ upsertAvsUserById apid
|
Just Entity{entityVal=UserAvs{userAvsPersonId = apid}} -> catchAll2log $ runDB $ updateAvsUserById apid
|
||||||
Nothing -> return ()
|
Nothing -> return ()
|
||||||
-- Retrieve updated user and supervisors now
|
-- Retrieve updated user and supervisors now
|
||||||
(underling :: Entity User, avsSupers :: [(E.Value UserId, E.Value (Maybe AvsPersonId))]) <- runDBRead $ (,)
|
(underling :: Entity User, avsSupers :: [(E.Value UserId, E.Value (Maybe AvsPersonId))]) <- runDBRead $ (,)
|
||||||
@ -195,7 +195,7 @@ updateReceivers uid = do
|
|||||||
receiverIDs :: [UserId] = E.unValue <$> superVs
|
receiverIDs :: [UserId] = E.unValue <$> superVs
|
||||||
toUpdate = Set.fromList $ mapMaybe E.unValue avsIds
|
toUpdate = Set.fromList $ mapMaybe E.unValue avsIds
|
||||||
directResult = return (underling, pure underling, True) -- already contains updated address
|
directResult = return (underling, pure underling, True) -- already contains updated address
|
||||||
forM_ toUpdate (catchAll2log . upsertAvsUserById) -- attempt to update postaddress from AVS
|
runDB $ forM_ toUpdate (catchAll2log . updateAvsUserById) -- attempt to update postaddress from AVS
|
||||||
if null receiverIDs
|
if null receiverIDs
|
||||||
then directResult
|
then directResult
|
||||||
else do
|
else do
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user