Web.ActivityPub: Ticket attachment's Offer object can be either URI or a Patch
This will allow to use this representation for Offer and Create activities. When creating a new MR, the inner Offer's 'object' is a 'Patch' object. When serving an existing hosted MR, the inner Offer's 'object' is just a URI pointing to the patch.
This commit is contained in:
parent
6d80b1e4f1
commit
75c0bc0939
2 changed files with 11 additions and 7 deletions
|
@ -194,8 +194,9 @@ getSharerPatchR shr talkhid = do
|
|||
Right (_, ro) ->
|
||||
remoteObjectIdent ro
|
||||
, mrPatch =
|
||||
encodeRouteHome $ SharerPatchVersionR shr talkhid $
|
||||
encodePatchId ptid
|
||||
Left $ encodeRouteHome $
|
||||
SharerPatchVersionR shr talkhid $
|
||||
encodePatchId ptid
|
||||
}
|
||||
)
|
||||
}
|
||||
|
@ -469,8 +470,9 @@ getRepoPatchR shr rp ltkhid = do
|
|||
Nothing -> RepoR shr rp
|
||||
Just b -> RepoBranchR shr rp b
|
||||
, mrPatch =
|
||||
encodeRouteHome $ RepoPatchVersionR shr rp ltkhid $
|
||||
encodePatchId ptid
|
||||
Left $ encodeRouteHome $
|
||||
RepoPatchVersionR shr rp ltkhid $
|
||||
encodePatchId ptid
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
@ -959,7 +959,7 @@ encodeTicketLocal
|
|||
data MergeRequest u = MergeRequest
|
||||
{ mrOrigin :: Maybe (ObjURI u)
|
||||
, mrTarget :: LocalURI
|
||||
, mrPatch :: ObjURI u
|
||||
, mrPatch :: Either (ObjURI u) (Authority u, Patch u)
|
||||
}
|
||||
|
||||
instance ActivityPub MergeRequest where
|
||||
|
@ -976,13 +976,15 @@ instance ActivityPub MergeRequest where
|
|||
MergeRequest
|
||||
<$> o .:? "origin"
|
||||
<*> pure target
|
||||
<*> o .: "object"
|
||||
<*> (second fromDoc . toEither <$> o .: "object")
|
||||
where
|
||||
fromDoc (Doc h v) = (h, v)
|
||||
|
||||
toSeries h (MergeRequest morigin target patch)
|
||||
= "type" .= ("Offer" :: Text)
|
||||
<> "origin" .=? morigin
|
||||
<> "target" .= ObjURI h target
|
||||
<> "object" .= patch
|
||||
<> "object" .= fromEither (second (uncurry Doc) patch)
|
||||
|
||||
data Ticket u = Ticket
|
||||
{ ticketLocal :: Maybe (Authority u, TicketLocal)
|
||||
|
|
Loading…
Reference in a new issue