mirror of
https://code.naskya.net/repos/ndqEd
synced 2025-03-20 15:14:54 +09:00
S2S: repoApplyF, for now only on remotely hosted patches
This commit is contained in:
parent
5491d0e495
commit
c3ff3c40eb
11 changed files with 489 additions and 66 deletions
src/Web
|
@ -1,6 +1,6 @@
|
|||
{- This file is part of Vervis.
|
||||
-
|
||||
- Written in 2019, 2020, 2021 by fr33domlover <fr33domlover@riseup.net>.
|
||||
- Written in 2019, 2020, 2021, 2022 by fr33domlover <fr33domlover@riseup.net>.
|
||||
-
|
||||
- ♡ Copying is an act of love. Please copy, reuse and share.
|
||||
-
|
||||
|
@ -62,6 +62,7 @@ module Web.ActivityPub
|
|||
, Accept (..)
|
||||
, AddObject (..)
|
||||
, Add (..)
|
||||
, Apply (..)
|
||||
, CreateObject (..)
|
||||
, Create (..)
|
||||
, Follow (..)
|
||||
|
@ -163,10 +164,10 @@ as2Context :: Text
|
|||
as2Context = "https://www.w3.org/ns/activitystreams"
|
||||
|
||||
secContext :: Text
|
||||
secContext = "https://w3id.org/security/v1"
|
||||
secContext = "https://w3id.org/security/v2"
|
||||
|
||||
forgeContext :: Text
|
||||
forgeContext = "https://forgefed.peers.community/ns"
|
||||
forgeContext = "https://forgefed.org/ns"
|
||||
|
||||
extContext :: Text
|
||||
extContext = "https://angeley.es/as2-ext"
|
||||
|
@ -1334,6 +1335,22 @@ encodeAdd h (Add obj target)
|
|||
Right o -> "object" `pair` pairs (toSeries h o)
|
||||
<> "target" .= target
|
||||
|
||||
data Apply u = Apply
|
||||
{ applyObject :: ObjURI u
|
||||
, applyTarget :: ObjURI u
|
||||
}
|
||||
|
||||
parseApply :: UriMode u => Object -> Parser (Apply u)
|
||||
parseApply o =
|
||||
Apply
|
||||
<$> o .: "object"
|
||||
<*> o .: "target"
|
||||
|
||||
encodeApply :: UriMode u => Apply u -> Series
|
||||
encodeApply (Apply obj target)
|
||||
= "object" .= obj
|
||||
<> "target" .= target
|
||||
|
||||
data CreateObject u = CreateNote (Note u) | CreateTicket (Ticket u)
|
||||
|
||||
instance ActivityPub CreateObject where
|
||||
|
@ -1488,15 +1505,16 @@ encodeUndo :: UriMode u => Authority u -> Undo u -> Series
|
|||
encodeUndo a (Undo obj) = "object" .= obj
|
||||
|
||||
data SpecificActivity u
|
||||
= AcceptActivity (Accept u)
|
||||
= AcceptActivity (Accept u)
|
||||
| AddActivity (Add u)
|
||||
| CreateActivity (Create u)
|
||||
| FollowActivity (Follow u)
|
||||
| OfferActivity (Offer u)
|
||||
| PushActivity (Push u)
|
||||
| RejectActivity (Reject u)
|
||||
| ApplyActivity (Apply u)
|
||||
| CreateActivity (Create u)
|
||||
| FollowActivity (Follow u)
|
||||
| OfferActivity (Offer u)
|
||||
| PushActivity (Push u)
|
||||
| RejectActivity (Reject u)
|
||||
| ResolveActivity (Resolve u)
|
||||
| UndoActivity (Undo u)
|
||||
| UndoActivity (Undo u)
|
||||
|
||||
data Activity u = Activity
|
||||
{ activityId :: Maybe LocalURI
|
||||
|
@ -1523,6 +1541,7 @@ instance ActivityPub Activity where
|
|||
case typ of
|
||||
"Accept" -> AcceptActivity <$> parseAccept a o
|
||||
"Add" -> AddActivity <$> parseAdd o a
|
||||
"Apply" -> ApplyActivity <$> parseApply o
|
||||
"Create" -> CreateActivity <$> parseCreate o a actor
|
||||
"Follow" -> FollowActivity <$> parseFollow o
|
||||
"Offer" -> OfferActivity <$> parseOffer o a actor
|
||||
|
@ -1545,6 +1564,7 @@ instance ActivityPub Activity where
|
|||
activityType :: SpecificActivity u -> Text
|
||||
activityType (AcceptActivity _) = "Accept"
|
||||
activityType (AddActivity _) = "Add"
|
||||
activityType (ApplyActivity _) = "Apply"
|
||||
activityType (CreateActivity _) = "Create"
|
||||
activityType (FollowActivity _) = "Follow"
|
||||
activityType (OfferActivity _) = "Offer"
|
||||
|
@ -1554,6 +1574,7 @@ instance ActivityPub Activity where
|
|||
activityType (UndoActivity _) = "Undo"
|
||||
encodeSpecific h _ (AcceptActivity a) = encodeAccept h a
|
||||
encodeSpecific h _ (AddActivity a) = encodeAdd h a
|
||||
encodeSpecific _ _ (ApplyActivity a) = encodeApply a
|
||||
encodeSpecific h u (CreateActivity a) = encodeCreate h u a
|
||||
encodeSpecific _ _ (FollowActivity a) = encodeFollow a
|
||||
encodeSpecific h u (OfferActivity a) = encodeOffer h u a
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue