mirror of
https://code.naskya.net/repos/ndqEd
synced 2025-03-20 15:14:54 +09:00
S2S: Switch from Grant->Accept->Enable to Invite->Accept->Grant
Giving access now starts with an Invite activity, followed by Accept from the Invite's recipient. Finally, the resource sends a Grant, which is the actual OCap.
This commit is contained in:
parent
0d96ee0775
commit
ac867e56f2
19 changed files with 697 additions and 532 deletions
src/Web
|
@ -71,6 +71,7 @@ module Web.ActivityPub
|
|||
, Create (..)
|
||||
, Follow (..)
|
||||
, Grant (..)
|
||||
, Invite (..)
|
||||
, OfferObject (..)
|
||||
, Offer (..)
|
||||
, Push (..)
|
||||
|
@ -1507,13 +1508,32 @@ data Grant u = Grant
|
|||
parseGrant :: UriMode u => Object -> Parser (Grant u)
|
||||
parseGrant o =
|
||||
Grant
|
||||
<$> o .: "object"
|
||||
<$> o .:+ "object"
|
||||
<*> o .: "context"
|
||||
<*> o .: "target"
|
||||
|
||||
encodeGrant :: UriMode u => Grant u -> Series
|
||||
encodeGrant (Grant obj context target)
|
||||
= "object" .= obj
|
||||
= "object" .=+ obj
|
||||
<> "context" .= context
|
||||
<> "target" .= target
|
||||
|
||||
data Invite u = Invite
|
||||
{ inviteInstrument :: Either Role (ObjURI u)
|
||||
, inviteObject :: ObjURI u
|
||||
, inviteTarget :: ObjURI u
|
||||
}
|
||||
|
||||
parseInvite :: UriMode u => Object -> Parser (Invite u)
|
||||
parseInvite o =
|
||||
Invite
|
||||
<$> o .:+ "instrument"
|
||||
<*> o .: "object"
|
||||
<*> o .: "target"
|
||||
|
||||
encodeInvite :: UriMode u => Invite u -> Series
|
||||
encodeInvite (Invite obj context target)
|
||||
= "object" .=+ obj
|
||||
<> "context" .= context
|
||||
<> "target" .= target
|
||||
|
||||
|
@ -1629,6 +1649,7 @@ data SpecificActivity u
|
|||
| CreateActivity (Create u)
|
||||
| FollowActivity (Follow u)
|
||||
| GrantActivity (Grant u)
|
||||
| InviteActivity (Invite u)
|
||||
| OfferActivity (Offer u)
|
||||
| PushActivity (Push u)
|
||||
| RejectActivity (Reject u)
|
||||
|
@ -1666,6 +1687,7 @@ instance ActivityPub Activity where
|
|||
"Create" -> CreateActivity <$> parseCreate o a actor
|
||||
"Follow" -> FollowActivity <$> parseFollow o
|
||||
"Grant" -> GrantActivity <$> parseGrant o
|
||||
"Invite" -> InviteActivity <$> parseInvite o
|
||||
"Offer" -> OfferActivity <$> parseOffer o a actor
|
||||
"Push" -> PushActivity <$> parsePush a o
|
||||
"Reject" -> RejectActivity <$> parseReject o
|
||||
|
@ -1691,6 +1713,7 @@ instance ActivityPub Activity where
|
|||
activityType (CreateActivity _) = "Create"
|
||||
activityType (FollowActivity _) = "Follow"
|
||||
activityType (GrantActivity _) = "Grant"
|
||||
activityType (InviteActivity _) = "Invite"
|
||||
activityType (OfferActivity _) = "Offer"
|
||||
activityType (PushActivity _) = "Push"
|
||||
activityType (RejectActivity _) = "Reject"
|
||||
|
@ -1702,6 +1725,7 @@ instance ActivityPub Activity where
|
|||
encodeSpecific _ _ (CreateActivity a) = encodeCreate a
|
||||
encodeSpecific _ _ (FollowActivity a) = encodeFollow a
|
||||
encodeSpecific _ _ (GrantActivity a) = encodeGrant a
|
||||
encodeSpecific _ _ (InviteActivity a) = encodeInvite a
|
||||
encodeSpecific h u (OfferActivity a) = encodeOffer h u a
|
||||
encodeSpecific h _ (PushActivity a) = encodePush h a
|
||||
encodeSpecific _ _ (RejectActivity a) = encodeReject a
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue