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,7 +194,8 @@ getSharerPatchR shr talkhid = do
|
||||||
Right (_, ro) ->
|
Right (_, ro) ->
|
||||||
remoteObjectIdent ro
|
remoteObjectIdent ro
|
||||||
, mrPatch =
|
, mrPatch =
|
||||||
encodeRouteHome $ SharerPatchVersionR shr talkhid $
|
Left $ encodeRouteHome $
|
||||||
|
SharerPatchVersionR shr talkhid $
|
||||||
encodePatchId ptid
|
encodePatchId ptid
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -469,7 +470,8 @@ getRepoPatchR shr rp ltkhid = do
|
||||||
Nothing -> RepoR shr rp
|
Nothing -> RepoR shr rp
|
||||||
Just b -> RepoBranchR shr rp b
|
Just b -> RepoBranchR shr rp b
|
||||||
, mrPatch =
|
, mrPatch =
|
||||||
encodeRouteHome $ RepoPatchVersionR shr rp ltkhid $
|
Left $ encodeRouteHome $
|
||||||
|
RepoPatchVersionR shr rp ltkhid $
|
||||||
encodePatchId ptid
|
encodePatchId ptid
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -959,7 +959,7 @@ encodeTicketLocal
|
||||||
data MergeRequest u = MergeRequest
|
data MergeRequest u = MergeRequest
|
||||||
{ mrOrigin :: Maybe (ObjURI u)
|
{ mrOrigin :: Maybe (ObjURI u)
|
||||||
, mrTarget :: LocalURI
|
, mrTarget :: LocalURI
|
||||||
, mrPatch :: ObjURI u
|
, mrPatch :: Either (ObjURI u) (Authority u, Patch u)
|
||||||
}
|
}
|
||||||
|
|
||||||
instance ActivityPub MergeRequest where
|
instance ActivityPub MergeRequest where
|
||||||
|
@ -976,13 +976,15 @@ instance ActivityPub MergeRequest where
|
||||||
MergeRequest
|
MergeRequest
|
||||||
<$> o .:? "origin"
|
<$> o .:? "origin"
|
||||||
<*> pure target
|
<*> pure target
|
||||||
<*> o .: "object"
|
<*> (second fromDoc . toEither <$> o .: "object")
|
||||||
|
where
|
||||||
|
fromDoc (Doc h v) = (h, v)
|
||||||
|
|
||||||
toSeries h (MergeRequest morigin target patch)
|
toSeries h (MergeRequest morigin target patch)
|
||||||
= "type" .= ("Offer" :: Text)
|
= "type" .= ("Offer" :: Text)
|
||||||
<> "origin" .=? morigin
|
<> "origin" .=? morigin
|
||||||
<> "target" .= ObjURI h target
|
<> "target" .= ObjURI h target
|
||||||
<> "object" .= patch
|
<> "object" .= fromEither (second (uncurry Doc) patch)
|
||||||
|
|
||||||
data Ticket u = Ticket
|
data Ticket u = Ticket
|
||||||
{ ticketLocal :: Maybe (Authority u, TicketLocal)
|
{ ticketLocal :: Maybe (Authority u, TicketLocal)
|
||||||
|
|
Loading…
Reference in a new issue