Use orderedItems in OrderedCollection

This commit is contained in:
fr33domlover 2019-11-06 20:46:21 +00:00
parent f8dd72d052
commit 7a96d904f3

View file

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