mirror of
https://code.sup39.dev/repos/Wqawg
synced 2024-12-28 23:44:51 +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)
|
<> "current" .=? (ObjURI authority <$> curr)
|
||||||
<> "first" .=? (PageURI authority <$> firzt)
|
<> "first" .=? (PageURI authority <$> firzt)
|
||||||
<> "last" .=? (PageURI authority <$> last)
|
<> "last" .=? (PageURI authority <$> last)
|
||||||
<> "items" .=% items
|
<> itemsProp .=% items
|
||||||
|
where
|
||||||
|
itemsProp =
|
||||||
|
case typ of
|
||||||
|
CollectionTypeUnordered -> "items"
|
||||||
|
CollectionTypeOrdered -> "orderedItems"
|
||||||
|
|
||||||
data CollectionPageType
|
data CollectionPageType
|
||||||
= CollectionPageTypeUnordered
|
= CollectionPageTypeUnordered
|
||||||
|
@ -527,7 +532,12 @@ instance (FromJSON a, ToJSON a) => ActivityPub (CollectionPage a) where
|
||||||
<> "prev" .=? (PageURI authority <$> prev)
|
<> "prev" .=? (PageURI authority <$> prev)
|
||||||
<> "next" .=? (PageURI authority <$> next)
|
<> "next" .=? (PageURI authority <$> next)
|
||||||
<> "startIndex" .=? ind
|
<> "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)
|
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
|
parsePush a o = do
|
||||||
c <- o .: "object"
|
c <- o .: "object"
|
||||||
Push
|
Push
|
||||||
<$> (traverse (withAuthorityT a . parseObject) =<< c .: "items")
|
<$> (traverse (withAuthorityT a . parseObject) =<< c .: "items" <|> c .: "orderedItems")
|
||||||
<*> (traverse (traverse $ withAuthorityT a . parseObject) =<< c .:? "earlyItems")
|
<*> (traverse (traverse $ withAuthorityT a . parseObject) =<< c .:? "earlyItems")
|
||||||
<*> c .: "totalItems"
|
<*> c .: "totalItems"
|
||||||
<*> withAuthorityO a (o .: "target")
|
<*> 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)
|
encodePush a (Push lateCommits earlyCommits total target context before after)
|
||||||
= "object" `pair` pairs
|
= "object" `pair` pairs
|
||||||
( "type" .= ("OrderedCollection" :: Text)
|
( "type" .= ("OrderedCollection" :: Text)
|
||||||
<> pair "items" (objectList lateCommits)
|
<> pair "orderedItems" (objectList lateCommits)
|
||||||
<> maybe mempty (pair "earlyItems" . objectList) earlyCommits
|
<> maybe mempty (pair "earlyItems" . objectList) earlyCommits
|
||||||
<> "totalItems" .= total
|
<> "totalItems" .= total
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue