mirror of
https://code.naskya.net/repos/ndqEd
synced 2025-03-20 15:14:54 +09:00
Web.ActivityPub: In MR, the 'object' of the 'Offer' is a 'Patch' URI
Instead of an 'OrderedCollection' of the versions
This commit is contained in:
parent
216aaa72ee
commit
6d80b1e4f1
2 changed files with 33 additions and 39 deletions
src/Web
|
@ -958,8 +958,8 @@ encodeTicketLocal
|
|||
|
||||
data MergeRequest u = MergeRequest
|
||||
{ mrOrigin :: Maybe (ObjURI u)
|
||||
, mrTarget :: ObjURI u
|
||||
, mrPatch :: NonEmpty LocalURI
|
||||
, mrTarget :: LocalURI
|
||||
, mrPatch :: ObjURI u
|
||||
}
|
||||
|
||||
instance ActivityPub MergeRequest where
|
||||
|
@ -969,30 +969,20 @@ instance ActivityPub MergeRequest where
|
|||
typ <- o .: "type"
|
||||
unless (typ == ("Offer" :: Text)) $
|
||||
fail "type isn't Offer"
|
||||
(hPatch, patches) <- do
|
||||
c <- o .: "object"
|
||||
ctyp <- c .: "type"
|
||||
unless (ctyp == ("OrderedCollection" :: Text)) $
|
||||
fail "type isn't OrderedCollection"
|
||||
ObjURI h lu :| us <- c .: "items" <|> c .: "orderedItems"
|
||||
let (hs, lus) = unzip $ map (\ (ObjURI h lu) -> (h, lu)) us
|
||||
unless (all (== h) hs) $ fail "Version hosts differ"
|
||||
return (h, lu :| lus)
|
||||
fmap (hPatch,) $
|
||||
|
||||
ObjURI a target <- o .: "target"
|
||||
|
||||
fmap (a,) $
|
||||
MergeRequest
|
||||
<$> o .:? "origin"
|
||||
<*> o .: "target"
|
||||
<*> pure patches
|
||||
<*> pure target
|
||||
<*> o .: "object"
|
||||
|
||||
toSeries hPatch (MergeRequest morigin target patches)
|
||||
toSeries h (MergeRequest morigin target patch)
|
||||
= "type" .= ("Offer" :: Text)
|
||||
<> "origin" .=? morigin
|
||||
<> "target" .= target
|
||||
<> "object" .= object
|
||||
[ "type" .= ("OrderedCollection" :: Text)
|
||||
, "totalItems" .= length patches
|
||||
, "orderedItems" .= NE.map (ObjURI hPatch) patches
|
||||
]
|
||||
<> "target" .= ObjURI h target
|
||||
<> "object" .= patch
|
||||
|
||||
data Ticket u = Ticket
|
||||
{ ticketLocal :: Maybe (Authority u, TicketLocal)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue