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 (..)
|
||||
, 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
|
||||
|
@ -1372,13 +1384,14 @@ instance ActivityPub Activity where
|
|||
<*> do
|
||||
typ <- o .: "type"
|
||||
case typ of
|
||||
"Accept" -> AcceptActivity <$> parseAccept a o
|
||||
"Create" -> CreateActivity <$> parseCreate o a actor
|
||||
"Follow" -> FollowActivity <$> parseFollow o
|
||||
"Offer" -> OfferActivity <$> parseOffer o a actor
|
||||
"Push" -> PushActivity <$> parsePush a o
|
||||
"Reject" -> RejectActivity <$> parseReject o
|
||||
"Undo" -> UndoActivity <$> parseUndo a o
|
||||
"Accept" -> AcceptActivity <$> parseAccept a o
|
||||
"Create" -> CreateActivity <$> parseCreate o a actor
|
||||
"Follow" -> FollowActivity <$> parseFollow o
|
||||
"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 $
|
||||
"Unrecognized activity type: " ++ T.unpack typ
|
||||
|
@ -1391,20 +1404,22 @@ instance ActivityPub Activity where
|
|||
<> encodeSpecific authority actor specific
|
||||
where
|
||||
activityType :: SpecificActivity u -> Text
|
||||
activityType (AcceptActivity _) = "Accept"
|
||||
activityType (CreateActivity _) = "Create"
|
||||
activityType (FollowActivity _) = "Follow"
|
||||
activityType (OfferActivity _) = "Offer"
|
||||
activityType (PushActivity _) = "Push"
|
||||
activityType (RejectActivity _) = "Reject"
|
||||
activityType (UndoActivity _) = "Undo"
|
||||
encodeSpecific h _ (AcceptActivity a) = encodeAccept h a
|
||||
encodeSpecific h u (CreateActivity a) = encodeCreate h u a
|
||||
encodeSpecific _ _ (FollowActivity a) = encodeFollow a
|
||||
encodeSpecific h u (OfferActivity a) = encodeOffer h u a
|
||||
encodeSpecific h _ (PushActivity a) = encodePush h a
|
||||
encodeSpecific _ _ (RejectActivity a) = encodeReject a
|
||||
encodeSpecific h _ (UndoActivity a) = encodeUndo h a
|
||||
activityType (AcceptActivity _) = "Accept"
|
||||
activityType (CreateActivity _) = "Create"
|
||||
activityType (FollowActivity _) = "Follow"
|
||||
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
|
||||
encodeSpecific _ _ (FollowActivity a) = encodeFollow a
|
||||
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
|
||||
emptyAudience = Audience [] [] [] [] [] []
|
||||
|
|
Loading…
Reference in a new issue