From ef8151c7cb77572b139a4321d225fa3ff6fb592b Mon Sep 17 00:00:00 2001 From: Pere Lev Date: Mon, 1 Jul 2024 18:27:16 +0300 Subject: [PATCH] S2S: Project: Upon component-Revoke-start-Grant, remove whole Component record --- src/Vervis/Actor/Project.hs | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/src/Vervis/Actor/Project.hs b/src/Vervis/Actor/Project.hs index c9e36ba..78ac854 100644 --- a/src/Vervis/Actor/Project.hs +++ b/src/Vervis/Actor/Project.hs @@ -6887,7 +6887,7 @@ projectRemove now projectID (Verse authorIdMsig body) remove = do -- * Forward the Revoke to my followers -- * Send Accept to team+followers & my followers -- * If it's a component revoking a Grant it had extended to me: --- * Delete that extension from my Component record +-- * Delete the whole Component record -- * For each further extension I did on that Grant (to a -- parent/collab/team), send a Revoke projectRevoke @@ -7021,7 +7021,7 @@ projectRevoke now projectID (Verse authorIdMsig body) (AP.Revoke (luFirst :| lus tryComponent' componentID component = do lift $ verifyComponentHolder componentID enableID <- lift $ MaybeT $ getKeyBy $ UniqueComponentEnable componentID - return (enableID, component) + return (componentID, enableID, component) tryComponent (Left (_actorByKey, _actorEntity, itemID)) = do Entity delegID (ComponentDelegateLocal topicID _) <- @@ -7400,7 +7400,7 @@ projectRevoke now projectID (Verse authorIdMsig body) (AP.Revoke (luFirst :| lus return (action, recipientSet, remoteActors, fwdHosts) - revokeComponent revokedRest (enableID, component) = do + revokeComponent revokedRest (componentID, enableID, component) = do let author = bimap (view _1) (remoteAuthorId . view _1) authorIdMsig unless (author == bimap (resourceToActor . componentResource . view _2) (view _2) component) $ @@ -7434,6 +7434,33 @@ projectRevoke now projectID (Verse authorIdMsig body) (AP.Revoke (luFirst :| lus Left (_, _, _, delegID) -> delete delegID Right (_, _, delegID) -> delete delegID + -- Delete the whole Component record + usOrThem <- + requireEitherAlt + (getKeyBy $ UniqueComponentOriginInvite componentID) + (getKeyBy $ UniqueComponentOriginAdd componentID) + "Neither us nor them" + "Both us and them" + delete enableID + case usOrThem of + Left usID -> do + deleteBy $ UniqueComponentProjectAccept usID + delete usID + Right themID -> do + deleteBy $ UniqueComponentGestureLocal themID + deleteBy $ UniqueComponentGestureRemote themID + delete themID + deleteBy $ UniqueComponentProjectGestureLocal componentID + deleteBy $ UniqueComponentProjectGestureRemote componentID + case component of + Left (localID, _, _, _) -> do + deleteBy $ UniqueComponentAcceptLocal localID + delete localID + Right (remoteID, _, _) -> do + deleteBy $ UniqueComponentAcceptRemote remoteID + delete remoteID + delete componentID + -- Prepare and insert Revokes on all the extension-Grants revokesFL <- for furthersL $ \ (Entity _ (ComponentFurtherLocal _ delegID grantID)) -> do CollabDelegLocal _ recipID _ <- getJust delegID @@ -7478,7 +7505,7 @@ projectRevoke now projectID (Verse authorIdMsig body) (AP.Revoke (luFirst :| lus sendActivity topicByID topicActorID localRecipsExt remoteRecipsExt fwdHostsExt extID actionExt - doneDB inboxItemID "Deleted the ComponentDelegate* record, sent Revokes" + doneDB inboxItemID "Deleted the Component record, sent Revokes" where