diff --git a/src/Vervis/API.hs b/src/Vervis/API.hs index 61d7dcd..e4a64fc 100644 --- a/src/Vervis/API.hs +++ b/src/Vervis/API.hs @@ -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 diff --git a/src/Vervis/Handler/Person.hs b/src/Vervis/Handler/Person.hs index 8044612..f60c9c3 100644 --- a/src/Vervis/Handler/Person.hs +++ b/src/Vervis/Handler/Person.hs @@ -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 diff --git a/src/Vervis/Migration.hs b/src/Vervis/Migration.hs index b109531..7510620 100644 --- a/src/Vervis/Migration.hs +++ b/src/Vervis/Migration.hs @@ -568,6 +568,7 @@ changes hLocal ctx = , activityCapability = Nothing , activitySummary = Nothing , activityAudience = Audience [] [] [] [] [] [] + , activityFulfills = [] , activitySpecific = RejectActivity $ Reject fedUri } insertEntity $ OutboxItem20190612 pid (persistJSONObjectFromDoc doc) defaultTime diff --git a/src/Web/ActivityPub.hs b/src/Web/ActivityPub.hs index 48a2a40..b2bc6f9 100644 --- a/src/Web/ActivityPub.hs +++ b/src/Web/ActivityPub.hs @@ -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 }