1
0
Fork 0
mirror of https://code.sup39.dev/repos/Wqawg synced 2024-12-29 01:04:52 +09:00

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 , actorName = sharerName sharer
, actorSummary = Nothing , actorSummary = Nothing
, actorInbox = route2local $ SharerInboxR shr , actorInbox = route2local $ SharerInboxR shr
, actorOutbox = Just $ route2local $ OutboxR shr
, actorPublicKeys = , actorPublicKeys =
[ Left $ route2local ActorKey1R [ Left $ route2local ActorKey1R
, Left $ route2local ActorKey2R , Left $ route2local ActorKey2R

View file

@ -140,6 +140,7 @@ getProjectR shar proj = selectRep $ do
Just $ fromMaybe (prj2text proj) $ projectName project Just $ fromMaybe (prj2text proj) $ projectName project
, actorSummary = projectDesc project , actorSummary = projectDesc project
, actorInbox = route2local $ ProjectInboxR shar proj , actorInbox = route2local $ ProjectInboxR shar proj
, actorOutbox = Nothing
, actorPublicKeys = , actorPublicKeys =
[ Left $ route2local ActorKey1R [ Left $ route2local ActorKey1R
, Left $ route2local ActorKey2R , Left $ route2local ActorKey2R

View file

@ -303,6 +303,7 @@ data Actor = Actor
, actorName :: Maybe Text , actorName :: Maybe Text
, actorSummary :: Maybe Text , actorSummary :: Maybe Text
, actorInbox :: LocalURI , actorInbox :: LocalURI
, actorOutbox :: Maybe LocalURI
, actorPublicKeys :: [Either LocalURI PublicKey] , actorPublicKeys :: [Either LocalURI PublicKey]
} }
@ -317,6 +318,7 @@ instance ActivityPub Actor where
<*> o .:? "name" <*> o .:? "name"
<*> o .:? "summary" <*> o .:? "summary"
<*> withHost host (f2l <$> o .: "inbox") <*> withHost host (f2l <$> o .: "inbox")
<*> withHostMaybe host (fmap f2l <$> o .:? "outbox")
<*> withHost host (parsePublicKeySet =<< o .: "publicKey") <*> withHost host (parsePublicKeySet =<< o .: "publicKey")
where where
withHost h a = do withHost h a = do
@ -324,13 +326,14 @@ instance ActivityPub Actor where
if h == h' if h == h'
then return v then return v
else fail "URI host mismatch" 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_ = "id" .= l2f host id_
<> "type" .= typ <> "type" .= typ
<> "preferredUsername" .=? musername <> "preferredUsername" .=? musername
<> "name" .=? mname <> "name" .=? mname
<> "summary" .=? msummary <> "summary" .=? msummary
<> "inbox" .= l2f host inbox <> "inbox" .= l2f host inbox
<> "outbox" .=? (l2f host <$> outbox)
<> "publicKey" `pair` encodePublicKeySet host pkeys <> "publicKey" `pair` encodePublicKeySet host pkeys
data CollectionType = CollectionTypeUnordered | CollectionTypeOrdered data CollectionType = CollectionTypeUnordered | CollectionTypeOrdered