Parse and publish actor outboxes

This commit is contained in:
fr33domlover 2019-05-21 00:36:05 +00:00
parent 40d9a0990d
commit 2573ff1d93
3 changed files with 6 additions and 1 deletions

View file

@ -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

View file

@ -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

View file

@ -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