ActivityPub: Move 'fulfills' property from Grant type to Activity type
This commit is contained in:
parent
26ec6527e2
commit
0bd7568ca5
4 changed files with 17 additions and 7 deletions
|
@ -1187,6 +1187,7 @@ createTicketTrackerC (Entity pidUser personUser) senderActor summary audience tr
|
|||
, activityCapability = Nothing
|
||||
, activitySummary = summary
|
||||
, activityAudience = blinded
|
||||
, activityFulfills = []
|
||||
, activitySpecific = CreateActivity Create
|
||||
{ createObject = CreateTicketTracker ttdetail (Just (hLocal, ttlocal))
|
||||
, createTarget = Nothing
|
||||
|
@ -1220,11 +1221,12 @@ createTicketTrackerC (Entity pidUser personUser) senderActor summary audience tr
|
|||
, activityCapability = Nothing
|
||||
, activitySummary = Nothing
|
||||
, activityAudience = Audience recips [] [] [] [] []
|
||||
, activityFulfills =
|
||||
[encodeRouteHome $ PersonOutboxItemR adminHash obikhidCreate]
|
||||
, activitySpecific = GrantActivity Grant
|
||||
{ grantObject = Left RoleAdmin
|
||||
, grantContext = encodeRouteHome $ DeckR deckHash
|
||||
, grantTarget = encodeRouteHome $ PersonR adminHash
|
||||
, grantFulfills = Just $ encodeRouteHome $ PersonOutboxItemR adminHash obikhidCreate
|
||||
}
|
||||
}
|
||||
update obiidGrant [OutboxItemActivity =. persistJSONObjectFromDoc grant]
|
||||
|
@ -1244,6 +1246,7 @@ createTicketTrackerC (Entity pidUser personUser) senderActor summary audience tr
|
|||
, activityCapability = Nothing
|
||||
, activitySummary = Nothing
|
||||
, activityAudience = AP.Audience recips [] [] [] [] []
|
||||
, activityFulfills = []
|
||||
, activitySpecific = FollowActivity AP.Follow
|
||||
{ AP.followObject = encodeRouteHome $ DeckR deckHash
|
||||
, AP.followContext = Nothing
|
||||
|
@ -1267,6 +1270,7 @@ createTicketTrackerC (Entity pidUser personUser) senderActor summary audience tr
|
|||
, activityCapability = Nothing
|
||||
, activitySummary = Nothing
|
||||
, activityAudience = Audience recips [] [] [] [] []
|
||||
, activityFulfills = []
|
||||
, activitySpecific = AcceptActivity Accept
|
||||
{ acceptObject = ObjURI hLocal luFollow
|
||||
, acceptResult = Nothing
|
||||
|
@ -1400,6 +1404,7 @@ followC (Entity pidSender personSender) summary audience follow@(AP.Follow uObje
|
|||
, activityCapability = Nothing
|
||||
, activitySummary = summary
|
||||
, activityAudience = blinded
|
||||
, activityFulfills = []
|
||||
, activitySpecific = FollowActivity follow
|
||||
}
|
||||
update obiid [OutboxItemActivity =. persistJSONObjectFromDoc doc]
|
||||
|
@ -1428,6 +1433,7 @@ followC (Entity pidSender personSender) summary audience follow@(AP.Follow uObje
|
|||
, activityCapability = Nothing
|
||||
, activitySummary = Just summary
|
||||
, activityAudience = Audience recips [] [] [] [] []
|
||||
, activityFulfills = []
|
||||
, activitySpecific = AcceptActivity Accept
|
||||
{ acceptObject = ObjURI hLocal luFollow
|
||||
, acceptResult = Nothing
|
||||
|
|
|
@ -141,6 +141,8 @@ postPersonOutboxR personHash = do
|
|||
|
||||
result <- runExceptT $ do
|
||||
verifyAttribution $ AP.activityActor activity
|
||||
unless (null $ AP.activityFulfills activity) $
|
||||
throwE "Specifying 'fulfills' manually isn't allowed currently"
|
||||
handle (Entity personID person) actor activity
|
||||
case result of
|
||||
Left err -> invalidArgs [err]
|
||||
|
@ -160,7 +162,7 @@ postPersonOutboxR personHash = do
|
|||
Just (PersonR actorHash) | actorHash == personHash -> return ()
|
||||
_ -> throwE "Can't post activity attributed to someone else"
|
||||
|
||||
handle eperson actorDB (AP.Activity _mid _actorAP mcap summary audience specific) =
|
||||
handle eperson actorDB (AP.Activity _mid _actorAP mcap summary audience _fulfills specific) =
|
||||
case specific of
|
||||
AP.CreateActivity (AP.Create obj mtarget) ->
|
||||
case obj of
|
||||
|
|
|
@ -568,6 +568,7 @@ changes hLocal ctx =
|
|||
, activityCapability = Nothing
|
||||
, activitySummary = Nothing
|
||||
, activityAudience = Audience [] [] [] [] [] []
|
||||
, activityFulfills = []
|
||||
, activitySpecific = RejectActivity $ Reject fedUri
|
||||
}
|
||||
insertEntity $ OutboxItem20190612 pid (persistJSONObjectFromDoc doc) defaultTime
|
||||
|
|
|
@ -1487,7 +1487,6 @@ data Grant u = Grant
|
|||
{ grantObject :: Either Role (ObjURI u)
|
||||
, grantContext :: ObjURI u
|
||||
, grantTarget :: ObjURI u
|
||||
, grantFulfills :: Maybe (ObjURI u)
|
||||
}
|
||||
|
||||
parseGrant :: UriMode u => Object -> Parser (Grant u)
|
||||
|
@ -1496,14 +1495,12 @@ parseGrant o =
|
|||
<$> o .: "object"
|
||||
<*> o .: "context"
|
||||
<*> o .: "target"
|
||||
<*> o .:? "fulfills"
|
||||
|
||||
encodeGrant :: UriMode u => Grant u -> Series
|
||||
encodeGrant (Grant obj context target mfulfills)
|
||||
encodeGrant (Grant obj context target)
|
||||
= "object" .= obj
|
||||
<> "context" .= context
|
||||
<> "target" .= target
|
||||
<> "fulfills" .=? mfulfills
|
||||
|
||||
data OfferObject u = OfferTicket (Ticket u) | OfferDep (TicketDependency u)
|
||||
|
||||
|
@ -1629,6 +1626,7 @@ data Activity u = Activity
|
|||
, activityCapability :: Maybe (ObjURI u)
|
||||
, activitySummary :: Maybe TextHtml
|
||||
, activityAudience :: Audience u
|
||||
, activityFulfills :: [ObjURI u]
|
||||
, activitySpecific :: SpecificActivity u
|
||||
}
|
||||
|
||||
|
@ -1643,6 +1641,7 @@ instance ActivityPub Activity where
|
|||
<*> o .:? "capability"
|
||||
<*> (fmap (TextHtml . sanitizeBalance) <$> o .:? "summary")
|
||||
<*> parseAudience o
|
||||
<*> o .:? "fulfills" .!= []
|
||||
<*> do
|
||||
typ <- o .: "type"
|
||||
case typ of
|
||||
|
@ -1660,13 +1659,14 @@ instance ActivityPub Activity where
|
|||
_ ->
|
||||
fail $
|
||||
"Unrecognized activity type: " ++ T.unpack typ
|
||||
toSeries authority (Activity id_ actor mcap summary audience specific)
|
||||
toSeries authority (Activity id_ actor mcap summary audience fulfills specific)
|
||||
= "type" .= activityType specific
|
||||
<> "id" .=? (ObjURI authority <$> id_)
|
||||
<> "actor" .= ObjURI authority actor
|
||||
<> "capability" .=? mcap
|
||||
<> "summary" .=? summary
|
||||
<> encodeAudience audience
|
||||
<> "fulfills" .=% fulfills
|
||||
<> encodeSpecific authority actor specific
|
||||
where
|
||||
activityType :: SpecificActivity u -> Text
|
||||
|
@ -1703,6 +1703,7 @@ emptyActivity = Activity
|
|||
, activityCapability = Nothing
|
||||
, activitySummary = Nothing
|
||||
, activityAudience = emptyAudience
|
||||
, activityFulfills = []
|
||||
, activitySpecific =
|
||||
RejectActivity $ Reject $ ObjURI (Authority "" Nothing) topLocalURI
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue