S2S: Project: Upon component-Revoke-start-Grant, remove whole Component record

This commit is contained in:
Pere Lev 2024-07-01 18:27:16 +03:00
parent 4d06d8e840
commit ef8151c7cb
No known key found for this signature in database
GPG key ID: 5252C5C863E5E57D

View file

@ -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