1
0
Fork 0
mirror of https://code.naskya.net/repos/ndqEd synced 2025-03-20 15:14:54 +09:00

C2S: grantC: Insert Collab records for Grants with remote topics too

This commit is contained in:
fr33domlover 2022-08-28 13:51:43 +00:00
parent 06c520f6aa
commit d741d0e918
4 changed files with 285 additions and 122 deletions

View file

@ -42,6 +42,7 @@ module Web.ActivityPub
, CollectionPageType (..)
, CollectionPage (..)
, Recipient (..)
, Resource (..)
-- * Content objects
, Note (..)
@ -99,6 +100,7 @@ module Web.ActivityPub
, fetchAPID
, fetchAPID'
, fetchRecipient
, fetchResource
, keyListedByActor
, fetchUnknownKey
, fetchKnownPersonalKey
@ -622,6 +624,19 @@ instance ActivityPub Recipient where
toSeries h (RecipientActor a) = toSeries h a
toSeries h (RecipientCollection c) = toSeries h c
data Resource u = ResourceActor (Actor u) | ResourceChild LocalURI LocalURI
instance ActivityPub Resource where
jsonldContext _ = [as2Context, secContext, forgeContext]
parseObject o =
second ResourceActor <$> parseObject o <|> do
ObjURI h luId <- o .: "id" <|> o .: "@id"
(h,) . ResourceChild luId <$> withAuthorityO h (o .: "managedBy")
toSeries h (ResourceActor a) = toSeries h a
toSeries h (ResourceChild luId luManager)
= "id" .= ObjURI h luId
<> "managedBy" .= ObjURI h luManager
data Audience u = Audience
{ audienceTo :: [ObjURI u]
, audienceBto :: [ObjURI u]
@ -1901,6 +1916,12 @@ fetchRecipient m = fetchAPID' m getId
getId (RecipientActor a) = actorId $ actorLocal a
getId (RecipientCollection c) = collectionId c
fetchResource :: (MonadIO m, UriMode u) => Manager -> Authority u -> LocalURI -> m (Either (Maybe APGetError) (Resource u))
fetchResource m = fetchAPID' m getId
where
getId (ResourceActor a) = actorId $ actorLocal a
getId (ResourceChild luId _) = luId
fetchAPID :: (MonadIO m, UriMode u, ActivityPub a) => Manager -> (a u -> LocalURI) -> Authority u -> LocalURI -> m (Either String (a u))
fetchAPID m getId h lu = first showError <$> fetchAPID' m getId h lu
where