mirror of
https://code.sup39.dev/repos/Wqawg
synced 2024-12-28 23:24:53 +09:00
Use orderedItems
in OrderedCollection
This commit is contained in:
parent
f8dd72d052
commit
7a96d904f3
1 changed files with 14 additions and 4 deletions
|
@ -466,7 +466,12 @@ instance (FromJSON a, ToJSON a) => ActivityPub (Collection a) where
|
|||
<> "current" .=? (ObjURI authority <$> curr)
|
||||
<> "first" .=? (PageURI authority <$> firzt)
|
||||
<> "last" .=? (PageURI authority <$> last)
|
||||
<> "items" .=% items
|
||||
<> itemsProp .=% items
|
||||
where
|
||||
itemsProp =
|
||||
case typ of
|
||||
CollectionTypeUnordered -> "items"
|
||||
CollectionTypeOrdered -> "orderedItems"
|
||||
|
||||
data CollectionPageType
|
||||
= CollectionPageTypeUnordered
|
||||
|
@ -527,7 +532,12 @@ instance (FromJSON a, ToJSON a) => ActivityPub (CollectionPage a) where
|
|||
<> "prev" .=? (PageURI authority <$> prev)
|
||||
<> "next" .=? (PageURI authority <$> next)
|
||||
<> "startIndex" .=? ind
|
||||
<> "items" .=% items
|
||||
<> itemsProp .=% items
|
||||
where
|
||||
itemsProp =
|
||||
case typ of
|
||||
CollectionPageTypeUnordered -> "items"
|
||||
CollectionPageTypeOrdered -> "orderedItems"
|
||||
|
||||
data Recipient u = RecipientActor (Actor u) | RecipientCollection (Collection (ObjURI u) u)
|
||||
|
||||
|
@ -1133,7 +1143,7 @@ parsePush :: UriMode u => Authority u -> Object -> Parser (Push u)
|
|||
parsePush a o = do
|
||||
c <- o .: "object"
|
||||
Push
|
||||
<$> (traverse (withAuthorityT a . parseObject) =<< c .: "items")
|
||||
<$> (traverse (withAuthorityT a . parseObject) =<< c .: "items" <|> c .: "orderedItems")
|
||||
<*> (traverse (traverse $ withAuthorityT a . parseObject) =<< c .:? "earlyItems")
|
||||
<*> c .: "totalItems"
|
||||
<*> withAuthorityO a (o .: "target")
|
||||
|
@ -1145,7 +1155,7 @@ encodePush :: UriMode u => Authority u -> Push u -> Series
|
|||
encodePush a (Push lateCommits earlyCommits total target context before after)
|
||||
= "object" `pair` pairs
|
||||
( "type" .= ("OrderedCollection" :: Text)
|
||||
<> pair "items" (objectList lateCommits)
|
||||
<> pair "orderedItems" (objectList lateCommits)
|
||||
<> maybe mempty (pair "earlyItems" . objectList) earlyCommits
|
||||
<> "totalItems" .= total
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue