mirror of
https://code.sup39.dev/repos/Wqawg
synced 2024-12-29 00:04:52 +09:00
Web.ActivityPub: Add a Resolve activity
This commit is contained in:
parent
1bd7995bb5
commit
58c0719370
1 changed files with 36 additions and 21 deletions
|
@ -66,6 +66,7 @@ module Web.ActivityPub
|
||||||
, Offer (..)
|
, Offer (..)
|
||||||
, Push (..)
|
, Push (..)
|
||||||
, Reject (..)
|
, Reject (..)
|
||||||
|
, Resolve (..)
|
||||||
, Undo (..)
|
, Undo (..)
|
||||||
, Audience (..)
|
, Audience (..)
|
||||||
, SpecificActivity (..)
|
, SpecificActivity (..)
|
||||||
|
@ -1332,6 +1333,16 @@ parseReject o = Reject <$> o .: "object"
|
||||||
encodeReject :: UriMode u => Reject u -> Series
|
encodeReject :: UriMode u => Reject u -> Series
|
||||||
encodeReject (Reject obj) = "object" .= obj
|
encodeReject (Reject obj) = "object" .= obj
|
||||||
|
|
||||||
|
data Resolve u = Resolve
|
||||||
|
{ resolveObject :: ObjURI u
|
||||||
|
}
|
||||||
|
|
||||||
|
parseResolve :: UriMode u => Object -> Parser (Resolve u)
|
||||||
|
parseResolve o = Resolve <$> o .: "object"
|
||||||
|
|
||||||
|
encodeResolve :: UriMode u => Resolve u -> Series
|
||||||
|
encodeResolve (Resolve obj) = "object" .= obj
|
||||||
|
|
||||||
data Undo u = Undo
|
data Undo u = Undo
|
||||||
{ undoObject :: LocalURI
|
{ undoObject :: LocalURI
|
||||||
}
|
}
|
||||||
|
@ -1349,6 +1360,7 @@ data SpecificActivity u
|
||||||
| OfferActivity (Offer u)
|
| OfferActivity (Offer u)
|
||||||
| PushActivity (Push u)
|
| PushActivity (Push u)
|
||||||
| RejectActivity (Reject u)
|
| RejectActivity (Reject u)
|
||||||
|
| ResolveActivity (Resolve u)
|
||||||
| UndoActivity (Undo u)
|
| UndoActivity (Undo u)
|
||||||
|
|
||||||
data Activity u = Activity
|
data Activity u = Activity
|
||||||
|
@ -1378,6 +1390,7 @@ instance ActivityPub Activity where
|
||||||
"Offer" -> OfferActivity <$> parseOffer o a actor
|
"Offer" -> OfferActivity <$> parseOffer o a actor
|
||||||
"Push" -> PushActivity <$> parsePush a o
|
"Push" -> PushActivity <$> parsePush a o
|
||||||
"Reject" -> RejectActivity <$> parseReject o
|
"Reject" -> RejectActivity <$> parseReject o
|
||||||
|
"Resolve" -> ResolveActivity <$> parseResolve o
|
||||||
"Undo" -> UndoActivity <$> parseUndo a o
|
"Undo" -> UndoActivity <$> parseUndo a o
|
||||||
_ ->
|
_ ->
|
||||||
fail $
|
fail $
|
||||||
|
@ -1397,6 +1410,7 @@ instance ActivityPub Activity where
|
||||||
activityType (OfferActivity _) = "Offer"
|
activityType (OfferActivity _) = "Offer"
|
||||||
activityType (PushActivity _) = "Push"
|
activityType (PushActivity _) = "Push"
|
||||||
activityType (RejectActivity _) = "Reject"
|
activityType (RejectActivity _) = "Reject"
|
||||||
|
activityType (ResolveActivity _) = "Resolve"
|
||||||
activityType (UndoActivity _) = "Undo"
|
activityType (UndoActivity _) = "Undo"
|
||||||
encodeSpecific h _ (AcceptActivity a) = encodeAccept h a
|
encodeSpecific h _ (AcceptActivity a) = encodeAccept h a
|
||||||
encodeSpecific h u (CreateActivity a) = encodeCreate h u a
|
encodeSpecific h u (CreateActivity a) = encodeCreate h u a
|
||||||
|
@ -1404,6 +1418,7 @@ instance ActivityPub Activity where
|
||||||
encodeSpecific h u (OfferActivity a) = encodeOffer h u a
|
encodeSpecific h u (OfferActivity a) = encodeOffer h u a
|
||||||
encodeSpecific h _ (PushActivity a) = encodePush h a
|
encodeSpecific h _ (PushActivity a) = encodePush h a
|
||||||
encodeSpecific _ _ (RejectActivity a) = encodeReject a
|
encodeSpecific _ _ (RejectActivity a) = encodeReject a
|
||||||
|
encodeSpecific _ _ (ResolveActivity a) = encodeResolve a
|
||||||
encodeSpecific h _ (UndoActivity a) = encodeUndo h a
|
encodeSpecific h _ (UndoActivity a) = encodeUndo h a
|
||||||
|
|
||||||
emptyAudience :: Audience u
|
emptyAudience :: Audience u
|
||||||
|
|
Loading…
Reference in a new issue