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

Web.ActivityPub: Add capability URI field to Activity type

This commit is contained in:
fr33domlover 2022-06-22 07:39:38 +00:00
parent bfa9774f83
commit 1e759698c1
8 changed files with 59 additions and 25 deletions

View file

@ -252,6 +252,7 @@ addBundleC (Entity pidUser personUser) sharerUser summary audience patches uTarg
doc = Doc hLocal Activity
{ activityId = Just luAct
, activityActor = encodeRouteLocal $ SharerR shrUser
, activityCapability = Nothing
, activitySummary = summary
, activityAudience = blinded
, activitySpecific =
@ -298,6 +299,7 @@ addBundleC (Entity pidUser personUser) sharerUser summary audience patches uTarg
Just $ encodeRouteLocal $
actorOutboxItem actor obikhidAccept
, activityActor = encodeRouteLocal $ renderLocalActor actor
, activityCapability = Nothing
, activitySummary = Nothing
, activityAudience = Audience recips [] [] [] [] []
, activitySpecific = AcceptActivity Accept
@ -668,6 +670,7 @@ createNoteC (Entity pidUser personUser) sharerUser summary audience note muTarge
create = Doc hLocal Activity
{ activityId = Just $ encodeRouteLocal $ SharerOutboxItemR shrUser obikhid
, activityActor = luAttrib
, activityCapability = Nothing
, activitySummary = summary
, activityAudience = blinded
, activitySpecific = CreateActivity Create
@ -1247,6 +1250,7 @@ createTicketC (Entity pidUser personUser) sharerUser summary audience ticket muT
create = Doc hLocal Activity
{ activityId = Just $ encodeRouteLocal $ SharerOutboxItemR shrUser obikhid
, activityActor = luAttrib
, activityCapability = Nothing
, activitySummary = summary
, activityAudience = blinded
, activitySpecific = CreateActivity Create
@ -1288,6 +1292,7 @@ createTicketC (Entity pidUser personUser) sharerUser summary audience ticket muT
accept = Doc hLocal Activity
{ activityId = Just $ encodeRouteLocal $ outboxItemRoute obikhidAccept
, activityActor = encodeRouteLocal actorRoute
, activityCapability = Nothing
, activitySummary = Nothing
, activityAudience = Audience recips [] [] [] [] []
, activitySpecific = AcceptActivity Accept
@ -1444,6 +1449,7 @@ followC shrUser summary audience follow@(AP.Follow uObject muContext hide) = do
let activity mluAct = Doc hLocal Activity
{ activityId = mluAct
, activityActor = encodeRouteLocal $ SharerR shrUser
, activityCapability = Nothing
, activitySummary = summary
, activityAudience = blinded
, activitySpecific = FollowActivity follow
@ -1487,6 +1493,7 @@ followC shrUser summary audience follow@(AP.Follow uObject muContext hide) = do
accept mluAct = Doc hLocal Activity
{ activityId = mluAct
, activityActor = objUriLocal uObject
, activityCapability = Nothing
, activitySummary = Just summary
, activityAudience = Audience recips [] [] [] [] []
, activitySpecific = AcceptActivity Accept
@ -1762,6 +1769,7 @@ offerTicketC (Entity pidUser personUser) sharerUser summary audience ticket uTar
doc = Doc hLocal Activity
{ activityId = Just luAct
, activityActor = encodeRouteLocal $ SharerR shrUser
, activityCapability = Nothing
, activitySummary = summary
, activityAudience = blinded
, activitySpecific =
@ -1838,6 +1846,7 @@ offerTicketC (Entity pidUser personUser) sharerUser summary audience ticket uTar
{ activityId =
Just $ encodeRouteLocal $ outboxItemRoute obikhidAccept
, activityActor = encodeRouteLocal projectRoute
, activityCapability = Nothing
, activitySummary = Nothing
, activityAudience = Audience recips [] [] [] [] []
, activitySpecific = AcceptActivity Accept
@ -2024,6 +2033,7 @@ offerDepC (Entity pidUser personUser) sharerUser summary audience dep uTarget =
doc = Doc hLocal Activity
{ activityId = Just luAct
, activityActor = encodeRouteLocal $ SharerR shrUser
, activityCapability = Nothing
, activitySummary = summary
, activityAudience = blinded
, activitySpecific =
@ -2098,6 +2108,7 @@ offerDepC (Entity pidUser personUser) sharerUser summary audience dep uTarget =
Just $ encodeRouteLocal $
actorOutboxItem actor obikhidAccept
, activityActor = encodeRouteLocal $ renderLocalActor actor
, activityCapability = Nothing
, activitySummary = Nothing
, activityAudience = Audience recips [] [] [] [] []
, activitySpecific = AcceptActivity Accept
@ -2142,6 +2153,7 @@ insertAcceptOnTicketStatus shrUser wi (WorkItemDetail _ ctx author) obiidResolve
Just $ encodeRouteLocal $
actorOutboxItem actor obikhidAccept
, activityActor = encodeRouteLocal $ renderLocalActor actor
, activityCapability = Nothing
, activitySummary = Nothing
, activityAudience = Audience recips [] [] [] [] []
, activitySpecific = AcceptActivity Accept
@ -2246,6 +2258,7 @@ resolveC (Entity pidUser personUser) sharerUser summary audience (Resolve uObjec
doc = Doc hLocal Activity
{ activityId = Just luAct
, activityActor = encodeRouteLocal $ SharerR shrUser
, activityCapability = Nothing
, activitySummary = summary
, activityAudience = blinded
, activitySpecific = ResolveActivity $ Resolve uObject
@ -2365,6 +2378,7 @@ undoC (Entity _pidUser personUser) sharerUser summary audience undo@(Undo uObjec
doc = Doc hLocal Activity
{ activityId = Just luAct
, activityActor = encodeRouteLocal $ SharerR shrUser
, activityCapability = Nothing
, activitySummary = summary
, activityAudience = blinded
, activitySpecific = UndoActivity $ Undo uObject
@ -2451,6 +2465,7 @@ pushCommitsC (eperson, sharer) summary push shrRepo rpRepo = do
activity mluAct = Doc host Activity
{ activityId = mluAct
, activityActor = encodeRouteLocal $ SharerR shrUser
, activityCapability = Nothing
, activitySummary =
Just $ TextHtml $ TL.toStrict $ renderHtml summary
, activityAudience = Audience aud [] [] [] [] []

View file

@ -384,6 +384,7 @@ followF
let accept luAct = Doc hLocal Activity
{ activityId = luAct
, activityActor = encodeRouteLocal recipRoute
, activityCapability = Nothing
, activitySummary = Just summary
, activityAudience = Audience [uAuthor] [] [] [] [] []
, activitySpecific = AcceptActivity Accept
@ -594,6 +595,7 @@ insertAcceptOnUndo actor author luUndo obiid auds = do
{ activityId =
Just $ encodeRouteLocal $ actorOutboxItem actor obikhid
, activityActor = encodeRouteLocal $ renderLocalActor actor
, activityCapability = Nothing
, activitySummary = Nothing
, activityAudience = Audience recips [] [] [] [] []
, activitySpecific = AcceptActivity Accept

View file

@ -382,6 +382,7 @@ projectOfferTicketF now shrRecip prjRecip author body mfwd luOffer ticket uTarge
Just $ encodeRouteLocal $
ProjectOutboxItemR shr prj obikhidAccept
, activityActor = encodeRouteLocal $ ProjectR shr prj
, activityCapability = Nothing
, activitySummary = Nothing
, activityAudience = Audience recips [] [] [] [] []
, activitySpecific = AcceptActivity Accept
@ -494,6 +495,7 @@ repoOfferTicketF now shrRecip rpRecip author body mfwd luOffer ticket uTarget =
Just $ encodeRouteLocal $
RepoOutboxItemR shr rp obikhidAccept
, activityActor = encodeRouteLocal $ RepoR shr rp
, activityCapability = Nothing
, activitySummary = Nothing
, activityAudience = Audience recips [] [] [] [] []
, activitySpecific = AcceptActivity Accept
@ -898,6 +900,7 @@ insertAcceptOnCreate collections outboxItemRoute actorRoute author luCreate tloc
{ activityId =
Just $ encodeRouteLocal $ outboxItemRoute obikhidAccept
, activityActor = encodeRouteLocal actorRoute
, activityCapability = Nothing
, activitySummary = Nothing
, activityAudience = Audience recips [] [] [] [] []
, activitySpecific = AcceptActivity Accept
@ -1251,6 +1254,7 @@ sharerAddBundleF now shrRecip author body mfwd luAdd patches uTarget = do
Just $ encodeRouteLocal $
SharerOutboxItemR shrRecip obikhidAccept
, activityActor = encodeRouteLocal $ SharerR shrRecip
, activityCapability = Nothing
, activitySummary = Nothing
, activityAudience = Audience recips [] [] [] [] []
, activitySpecific = AcceptActivity Accept
@ -1404,6 +1408,7 @@ repoAddBundleF now shrRecip rpRecip author body mfwd luAdd patches uTarget = do
Just $ encodeRouteLocal $
RepoOutboxItemR shrRecip rpRecip obikhidAccept
, activityActor = encodeRouteLocal $ RepoR shrRecip rpRecip
, activityCapability = Nothing
, activitySummary = Nothing
, activityAudience = Audience recips [] [] [] [] []
, activitySpecific = AcceptActivity Accept
@ -1563,6 +1568,7 @@ sharerOfferDepF now shrRecip author body mfwd luOffer dep uTarget = do
Just $ encodeRouteLocal $
SharerOutboxItemR shrRecip obikhidAccept
, activityActor = encodeRouteLocal $ SharerR shrRecip
, activityCapability = Nothing
, activitySummary = Nothing
, activityAudience = Audience recips [] [] [] [] []
, activitySpecific = AcceptActivity Accept
@ -1762,6 +1768,7 @@ projectOfferDepF now shrRecip prjRecip author body mfwd luOffer dep uTarget = do
Just $ encodeRouteLocal $
ProjectOutboxItemR shrRecip prjRecip obikhidAccept
, activityActor = encodeRouteLocal $ ProjectR shrRecip prjRecip
, activityCapability = Nothing
, activitySummary = Nothing
, activityAudience = Audience recips [] [] [] [] []
, activitySpecific = AcceptActivity Accept
@ -1923,6 +1930,7 @@ repoOfferDepF now shrRecip rpRecip author body mfwd luOffer dep uTarget = do
Just $ encodeRouteLocal $
RepoOutboxItemR shrRecip rpRecip obikhidAccept
, activityActor = encodeRouteLocal $ RepoR shrRecip rpRecip
, activityCapability = Nothing
, activitySummary = Nothing
, activityAudience = Audience recips [] [] [] [] []
, activitySpecific = AcceptActivity Accept
@ -2094,6 +2102,7 @@ sharerResolveF now shrRecip author body mfwd luResolve (Resolve uObject) = do
Just $ encodeRouteLocal $
SharerOutboxItemR shrRecip obikhidAccept
, activityActor = encodeRouteLocal $ SharerR shrRecip
, activityCapability = Nothing
, activitySummary = Nothing
, activityAudience = Audience recips [] [] [] [] []
, activitySpecific = AcceptActivity Accept
@ -2223,6 +2232,7 @@ projectResolveF now shrRecip prjRecip author body mfwd luResolve (Resolve uObjec
Just $ encodeRouteLocal $
ProjectOutboxItemR shrRecip prjRecip obikhidAccept
, activityActor = encodeRouteLocal $ ProjectR shrRecip prjRecip
, activityCapability = Nothing
, activitySummary = Nothing
, activityAudience = Audience recips [] [] [] [] []
, activitySpecific = AcceptActivity Accept
@ -2352,6 +2362,7 @@ repoResolveF now shrRecip rpRecip author body mfwd luResolve (Resolve uObject) =
Just $ encodeRouteLocal $
RepoOutboxItemR shrRecip rpRecip obikhidAccept
, activityActor = encodeRouteLocal $ RepoR shrRecip rpRecip
, activityCapability = Nothing
, activitySummary = Nothing
, activityAudience = Audience recips [] [] [] [] []
, activitySpecific = AcceptActivity Accept

View file

@ -370,7 +370,7 @@ postSharerOutboxR shr = do
obikhid <- encodeKeyHashid obiid
sendResponseCreated $ SharerOutboxItemR shr obikhid
where
handle eperson sharer (Activity _mid actor summary audience specific) = do
handle eperson sharer (Activity _mid actor _mcap summary audience specific) = do
case decodeRouteLocal actor of
Just (SharerR shr') | shr' == shr -> return ()
_ -> throwE "Can't post activity sttributed to someone else"

View file

@ -326,6 +326,7 @@ changes hLocal ctx =
doc = Doc h Activity
{ activityId = Nothing
, activityActor = localUri
, activityCapability = Nothing
, activitySummary = Nothing
, activityAudience = Audience [] [] [] [] [] []
, activitySpecific = RejectActivity $ Reject fedUri
@ -465,6 +466,7 @@ changes hLocal ctx =
activity luAct luNote = Doc hLocal Activity
{ activityId = Just luAct
, activityActor = luAttrib
, activityCapability = Nothing
, activitySummary = Nothing
, activityAudience = aud
, activitySpecific = CreateActivity Create
@ -719,6 +721,7 @@ changes hLocal ctx =
doc = Doc h Activity
{ activityId = Nothing
, activityActor = localUri
, activityCapability = Nothing
, activitySummary = Nothing
, activityAudience = Audience [] [] [] [] [] []
, activitySpecific = RejectActivity $ Reject fedUri
@ -782,6 +785,7 @@ changes hLocal ctx =
doc luAct = Doc hLocal Activity
{ activityId = Just luAct
, activityActor = author
, activityCapability = Nothing
, activitySummary =
Just $ TextHtml $ TL.toStrict $ renderHtml $
summary renderUrl
@ -884,6 +888,7 @@ changes hLocal ctx =
doc = Doc h Activity
{ activityId = Nothing
, activityActor = localUri
, activityCapability = Nothing
, activitySummary = Nothing
, activityAudience = Audience [] [] [] [] [] []
, activitySpecific = RejectActivity $ Reject fedUri
@ -940,6 +945,7 @@ changes hLocal ctx =
doc mluAct = Doc hLocal Activity
{ activityId = mluAct
, activityActor = author
, activityCapability = Nothing
, activitySummary =
Just $ TextHtml $ TL.toStrict $ renderHtml $
summary renderUrl

View file

@ -1,6 +1,6 @@
{- This file is part of Vervis.
-
- Written in 2016, 2018, 2019 by fr33domlover <fr33domlover@riseup.net>.
- Written in 2016, 2018, 2019, 2021 by fr33domlover <fr33domlover@riseup.net>.
-
- Copying is an act of love. Please copy, reuse and share.
-
@ -14,17 +14,12 @@
-}
module Vervis.Model.Role
( RepoOperation (..)
, ProjectOperation (..)
( ProjectOperation (..)
)
where
import Database.Persist.TH
data RepoOperation = RepoOpPush deriving (Eq, Show, Read, Enum, Bounded)
derivePersistField "RepoOperation"
data ProjectOperation
= ProjOpOpenTicket
| ProjOpAcceptTicket

View file

@ -1,6 +1,7 @@
{- This file is part of Vervis.
-
- Written in 2016, 2018, 2019, 2020 by fr33domlover <fr33domlover@riseup.net>.
- Written in 2016, 2018, 2019, 2020, 2021
- by fr33domlover <fr33domlover@riseup.net>.
-
- Copying is an act of love. Please copy, reuse and share.
-

View file

@ -1,6 +1,6 @@
{- This file is part of Vervis.
-
- Written in 2019, 2020 by fr33domlover <fr33domlover@riseup.net>.
- Written in 2019, 2020, 2021 by fr33domlover <fr33domlover@riseup.net>.
-
- Copying is an act of love. Please copy, reuse and share.
-
@ -1499,11 +1499,12 @@ data SpecificActivity u
| UndoActivity (Undo u)
data Activity u = Activity
{ activityId :: Maybe LocalURI
, activityActor :: LocalURI
, activitySummary :: Maybe TextHtml
, activityAudience :: Audience u
, activitySpecific :: SpecificActivity u
{ activityId :: Maybe LocalURI
, activityActor :: LocalURI
, activityCapability :: Maybe (ObjURI u)
, activitySummary :: Maybe TextHtml
, activityAudience :: Audience u
, activitySpecific :: SpecificActivity u
}
instance ActivityPub Activity where
@ -1514,6 +1515,7 @@ instance ActivityPub Activity where
Activity
<$> withAuthorityMaybeO a (o .:? "id")
<*> pure actor
<*> o .:? "capability"
<*> (fmap (TextHtml . sanitizeBalance) <$> o .:? "summary")
<*> parseAudience o
<*> do
@ -1531,11 +1533,12 @@ instance ActivityPub Activity where
_ ->
fail $
"Unrecognized activity type: " ++ T.unpack typ
toSeries authority (Activity id_ actor summary audience specific)
= "type" .= activityType specific
<> "id" .=? (ObjURI authority <$> id_)
<> "actor" .= ObjURI authority actor
<> "summary" .=? summary
toSeries authority (Activity id_ actor mcap summary audience specific)
= "type" .= activityType specific
<> "id" .=? (ObjURI authority <$> id_)
<> "actor" .= ObjURI authority actor
<> "capability" .=? mcap
<> "summary" .=? summary
<> encodeAudience audience
<> encodeSpecific authority actor specific
where
@ -1564,11 +1567,12 @@ emptyAudience = Audience [] [] [] [] [] []
emptyActivity :: Activity u
emptyActivity = Activity
{ activityId = Nothing
, activityActor = topLocalURI
, activitySummary = Nothing
, activityAudience = emptyAudience
, activitySpecific =
{ activityId = Nothing
, activityActor = topLocalURI
, activityCapability = Nothing
, activitySummary = Nothing
, activityAudience = emptyAudience
, activitySpecific =
RejectActivity $ Reject $ ObjURI (Authority "" Nothing) topLocalURI
}