diff --git a/src/Vervis/API.hs b/src/Vervis/API.hs index c400291..f689858 100644 --- a/src/Vervis/API.hs +++ b/src/Vervis/API.hs @@ -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 [] [] [] [] [] diff --git a/src/Vervis/Federation/Offer.hs b/src/Vervis/Federation/Offer.hs index 730d4c3..0c16137 100644 --- a/src/Vervis/Federation/Offer.hs +++ b/src/Vervis/Federation/Offer.hs @@ -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 diff --git a/src/Vervis/Federation/Ticket.hs b/src/Vervis/Federation/Ticket.hs index 09c9272..4f3f26c 100644 --- a/src/Vervis/Federation/Ticket.hs +++ b/src/Vervis/Federation/Ticket.hs @@ -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 diff --git a/src/Vervis/Handler/Client.hs b/src/Vervis/Handler/Client.hs index 5e80170..31accf2 100644 --- a/src/Vervis/Handler/Client.hs +++ b/src/Vervis/Handler/Client.hs @@ -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" diff --git a/src/Vervis/Migration.hs b/src/Vervis/Migration.hs index 5ce289c..d8f720e 100644 --- a/src/Vervis/Migration.hs +++ b/src/Vervis/Migration.hs @@ -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 diff --git a/src/Vervis/Model/Role.hs b/src/Vervis/Model/Role.hs index 7e0d0ba..4c861ff 100644 --- a/src/Vervis/Model/Role.hs +++ b/src/Vervis/Model/Role.hs @@ -1,6 +1,6 @@ {- This file is part of Vervis. - - - Written in 2016, 2018, 2019 by fr33domlover . + - Written in 2016, 2018, 2019, 2021 by fr33domlover . - - ♡ 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 diff --git a/src/Vervis/Ticket.hs b/src/Vervis/Ticket.hs index feed587..e783031 100644 --- a/src/Vervis/Ticket.hs +++ b/src/Vervis/Ticket.hs @@ -1,6 +1,7 @@ {- This file is part of Vervis. - - - Written in 2016, 2018, 2019, 2020 by fr33domlover . + - Written in 2016, 2018, 2019, 2020, 2021 + - by fr33domlover . - - ♡ Copying is an act of love. Please copy, reuse and share. - diff --git a/src/Web/ActivityPub.hs b/src/Web/ActivityPub.hs index ba03370..e25a9b5 100644 --- a/src/Web/ActivityPub.hs +++ b/src/Web/ActivityPub.hs @@ -1,6 +1,6 @@ {- This file is part of Vervis. - - - Written in 2019, 2020 by fr33domlover . + - Written in 2019, 2020, 2021 by fr33domlover . - - ♡ 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 }