1
0
Fork 0
mirror of https://code.sup39.dev/repos/Wqawg synced 2024-12-27 16:44:52 +09:00

Web.ActivityPub: Add a Resolve activity

This commit is contained in:
fr33domlover 2020-07-23 14:27:11 +00:00
parent 1bd7995bb5
commit 58c0719370

View file

@ -66,6 +66,7 @@ module Web.ActivityPub
, Offer (..)
, Push (..)
, Reject (..)
, Resolve (..)
, Undo (..)
, Audience (..)
, SpecificActivity (..)
@ -1332,6 +1333,16 @@ parseReject o = Reject <$> o .: "object"
encodeReject :: UriMode u => Reject u -> Series
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
{ undoObject :: LocalURI
}
@ -1349,6 +1360,7 @@ data SpecificActivity u
| OfferActivity (Offer u)
| PushActivity (Push u)
| RejectActivity (Reject u)
| ResolveActivity (Resolve u)
| UndoActivity (Undo u)
data Activity u = Activity
@ -1378,6 +1390,7 @@ instance ActivityPub Activity where
"Offer" -> OfferActivity <$> parseOffer o a actor
"Push" -> PushActivity <$> parsePush a o
"Reject" -> RejectActivity <$> parseReject o
"Resolve" -> ResolveActivity <$> parseResolve o
"Undo" -> UndoActivity <$> parseUndo a o
_ ->
fail $
@ -1397,6 +1410,7 @@ instance ActivityPub Activity where
activityType (OfferActivity _) = "Offer"
activityType (PushActivity _) = "Push"
activityType (RejectActivity _) = "Reject"
activityType (ResolveActivity _) = "Resolve"
activityType (UndoActivity _) = "Undo"
encodeSpecific h _ (AcceptActivity a) = encodeAccept h 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 _ (PushActivity a) = encodePush h a
encodeSpecific _ _ (RejectActivity a) = encodeReject a
encodeSpecific _ _ (ResolveActivity a) = encodeResolve a
encodeSpecific h _ (UndoActivity a) = encodeUndo h a
emptyAudience :: Audience u