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