From 2573ff1d931ed42780dbce6c8f94d6f5c428d2ca Mon Sep 17 00:00:00 2001 From: fr33domlover Date: Tue, 21 May 2019 00:36:05 +0000 Subject: [PATCH] Parse and publish actor outboxes --- src/Vervis/Handler/Person.hs | 1 + src/Vervis/Handler/Project.hs | 1 + src/Web/ActivityPub.hs | 5 ++++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Vervis/Handler/Person.hs b/src/Vervis/Handler/Person.hs index 721f3ae..5ec2012 100644 --- a/src/Vervis/Handler/Person.hs +++ b/src/Vervis/Handler/Person.hs @@ -143,6 +143,7 @@ getPerson shr sharer person = do , actorName = sharerName sharer , actorSummary = Nothing , actorInbox = route2local $ SharerInboxR shr + , actorOutbox = Just $ route2local $ OutboxR shr , actorPublicKeys = [ Left $ route2local ActorKey1R , Left $ route2local ActorKey2R diff --git a/src/Vervis/Handler/Project.hs b/src/Vervis/Handler/Project.hs index e9454ea..8b194a6 100644 --- a/src/Vervis/Handler/Project.hs +++ b/src/Vervis/Handler/Project.hs @@ -140,6 +140,7 @@ getProjectR shar proj = selectRep $ do Just $ fromMaybe (prj2text proj) $ projectName project , actorSummary = projectDesc project , actorInbox = route2local $ ProjectInboxR shar proj + , actorOutbox = Nothing , actorPublicKeys = [ Left $ route2local ActorKey1R , Left $ route2local ActorKey2R diff --git a/src/Web/ActivityPub.hs b/src/Web/ActivityPub.hs index 57e0a12..b88ac77 100644 --- a/src/Web/ActivityPub.hs +++ b/src/Web/ActivityPub.hs @@ -303,6 +303,7 @@ data Actor = Actor , actorName :: Maybe Text , actorSummary :: Maybe Text , actorInbox :: LocalURI + , actorOutbox :: Maybe LocalURI , actorPublicKeys :: [Either LocalURI PublicKey] } @@ -317,6 +318,7 @@ instance ActivityPub Actor where <*> o .:? "name" <*> o .:? "summary" <*> withHost host (f2l <$> o .: "inbox") + <*> withHostMaybe host (fmap f2l <$> o .:? "outbox") <*> withHost host (parsePublicKeySet =<< o .: "publicKey") where withHost h a = do @@ -324,13 +326,14 @@ instance ActivityPub Actor where if h == h' then return v else fail "URI host mismatch" - toSeries host (Actor id_ typ musername mname msummary inbox pkeys) + toSeries host (Actor id_ typ musername mname msummary inbox outbox pkeys) = "id" .= l2f host id_ <> "type" .= typ <> "preferredUsername" .=? musername <> "name" .=? mname <> "summary" .=? msummary <> "inbox" .= l2f host inbox + <> "outbox" .=? (l2f host <$> outbox) <> "publicKey" `pair` encodePublicKeySet host pkeys data CollectionType = CollectionTypeUnordered | CollectionTypeOrdered