UI: Removal form: Extend to work on children/parents as well

This commit is contained in:
Pere Lev 2024-04-18 22:52:26 +03:00
parent 7dcb225aa8
commit 1f36657084
No known key found for this signature in database
GPG key ID: 5252C5C863E5E57D
3 changed files with 10 additions and 11 deletions

View file

@ -1273,12 +1273,12 @@ remove
-> FedURI
-> FedURI
-> ExceptT Text Handler (Maybe HTML, [Aud URIMode], AP.Remove URIMode)
remove personID uRecipient uResourceCollabs = do
remove personID uRecipient uCollection = do
theater <- asksSite appTheater
env <- asksSite appEnv
let activity = AP.Remove uRecipient uResourceCollabs
let activity = AP.Remove uRecipient uCollection
(resource, recipient) <-
runActE $ parseRemove (Left $ LocalActorPerson personID) activity
@ -1291,9 +1291,7 @@ remove personID uRecipient uResourceCollabs = do
manager <- asksSite appHttpManager
coll <- ExceptT $ liftIO $ first T.pack <$> AP.fetchAPID manager AP.collectionId h luColl
lu <- fromMaybeE (AP.collectionContext (coll :: AP.Collection FedURI URIMode)) "Remote topic collabs has no 'context'"
AP.ResourceWithCollections _ mluCollabs _ mluMembers <- ExceptT $ liftIO $ first (T.pack . show) <$> AP.fetchRWC manager h lu
unless (mluCollabs == Just luColl || mluMembers == Just luColl) $
throwE "Remove origin isn't a collabs list"
AP.ResourceWithCollections _ _mluCollabs _ _mluMembers <- ExceptT $ liftIO $ first (T.pack . show) <$> AP.fetchRWC manager h lu
return $ ObjURI h lu
)
resource

View file

@ -1578,8 +1578,8 @@ postPublishAcceptR = do
redirect HomeR
removeForm = renderDivs $ (,,)
<$> areq fedUriField "(URI) Whom to remove" Nothing
<*> areq fedUriField "(URI) From which resource collaborators collection" Nothing
<$> areq fedUriField "(URI) Whom to remove" Nothing
<*> areq fedUriField "(URI) From which collection" Nothing
<*> areq capField "(URI) Grant activity to use for authorization" Nothing
getPublishRemoveR :: Handler Html
@ -1587,7 +1587,7 @@ getPublishRemoveR = do
((_, widget), enctype) <- runFormPost removeForm
defaultLayout
[whamlet|
<h1>Remove someone from a resource
<h1>Remove an actor from a collaborators/components/children/parents collection
<form method=POST action=@{PublishRemoveR} enctype=#{enctype}>
^{widget}
<input type=submit>
@ -1598,14 +1598,14 @@ postPublishRemoveR = do
federation <- getsYesod $ appFederation . appSettings
unless federation badMethod
(uRecipient, uResourceCollabs, (uCap, cap)) <-
(uRecipient, uCollection, (uCap, cap)) <-
runFormPostRedirect PublishRemoveR removeForm
(ep@(Entity pid _), a) <- getSender
senderHash <- encodeKeyHashid pid
result <- runExceptT $ do
(maybeSummary, audience, rmv) <- remove pid uRecipient uResourceCollabs
(maybeSummary, audience, rmv) <- remove pid uRecipient uCollection
(localRecips, remoteRecips, fwdHosts, action) <-
makeServerInput (Just uCap) maybeSummary audience (AP.RemoveActivity rmv)
handleViaActor pid (Just cap) localRecips remoteRecips fwdHosts action

View file

@ -62,7 +62,8 @@ $# Comment on a ticket or merge request
Invite someone to a resource
<li>
<a href=@{PublishRemoveR}>
Remove someone from a resource
Remove a collaborator/component/project/team from a
component/project/team/child/parent
<li>
<a href=@{PublishAddR}>
Add a component/child/parent to a project/team