diff --git a/src/Vervis/Handler/Deck.hs b/src/Vervis/Handler/Deck.hs index 16f2550..d6ffc51 100644 --- a/src/Vervis/Handler/Deck.hs +++ b/src/Vervis/Handler/Deck.hs @@ -171,6 +171,8 @@ getDeckR deckHash = do } } , AP.ticketTrackerTeam = Nothing + , AP.ticketTrackerCollaborators = + encodeRouteLocal $ DeckCollabsR deckHash } followButton = followW diff --git a/src/Vervis/Handler/Loom.hs b/src/Vervis/Handler/Loom.hs index 607a17d..65b7e9e 100644 --- a/src/Vervis/Handler/Loom.hs +++ b/src/Vervis/Handler/Loom.hs @@ -112,26 +112,30 @@ getLoomR loomHash = do hashSigKey <- getEncodeKeyHashid perActor <- asksSite $ appPerActorKeys . appSettings let route mk = encodeRouteLocal $ mk loomHash - loomAP = AP.Actor - { AP.actorLocal = AP.ActorLocal - { AP.actorId = route LoomR - , AP.actorInbox = route LoomInboxR - , AP.actorOutbox = Just $ route LoomOutboxR - , AP.actorFollowers = Just $ route LoomFollowersR - , AP.actorFollowing = Nothing - , AP.actorPublicKeys = - map (Left . encodeRouteLocal) $ - if perActor - then map (LoomStampR loomHash . hashSigKey) sigKeyIDs - else [ActorKey1R, ActorKey2R] - , AP.actorSshKeys = [] - } - , AP.actorDetail = AP.ActorDetail - { AP.actorType = AP.ActorTypePatchTracker - , AP.actorUsername = Nothing - , AP.actorName = Just $ actorName actor - , AP.actorSummary = Just $ actorDesc actor + loomAP = AP.PatchTracker + { AP.patchTrackerActor = AP.Actor + { AP.actorLocal = AP.ActorLocal + { AP.actorId = route LoomR + , AP.actorInbox = route LoomInboxR + , AP.actorOutbox = Just $ route LoomOutboxR + , AP.actorFollowers = Just $ route LoomFollowersR + , AP.actorFollowing = Nothing + , AP.actorPublicKeys = + map (Left . encodeRouteLocal) $ + if perActor + then map (LoomStampR loomHash . hashSigKey) sigKeyIDs + else [ActorKey1R, ActorKey2R] + , AP.actorSshKeys = [] + } + , AP.actorDetail = AP.ActorDetail + { AP.actorType = AP.ActorTypePatchTracker + , AP.actorUsername = Nothing + , AP.actorName = Just $ actorName actor + , AP.actorSummary = Just $ actorDesc actor + } } + , AP.patchTrackerCollaborators = + encodeRouteLocal $ LoomCollabsR loomHash } provideHtmlAndAP loomAP $ redirect $ LoomClothsR loomHash diff --git a/src/Vervis/Handler/Repo.hs b/src/Vervis/Handler/Repo.hs index 2438591..9bb50b4 100644 --- a/src/Vervis/Handler/Repo.hs +++ b/src/Vervis/Handler/Repo.hs @@ -232,6 +232,7 @@ getRepoR repoHash = do , AP.repoLoom = encodeRouteLocal . LoomR . hashLoom <$> repoLoom repo , AP.repoClone = encodeRouteLocal (RepoR repoHash) :| [] + , AP.repoCollaborators = encodeRouteLocal $ RepoCollabsR repoHash } next = diff --git a/src/Web/ActivityPub.hs b/src/Web/ActivityPub.hs index 8b0e80d..e1b8131 100644 --- a/src/Web/ActivityPub.hs +++ b/src/Web/ActivityPub.hs @@ -42,6 +42,7 @@ module Web.ActivityPub , Actor (..) , Repo (..) , TicketTracker (..) + , PatchTracker (..) , CollectionType (..) , Collection (..) , CollectionPageType (..) @@ -639,6 +640,7 @@ data Repo u = Repo , repoVcs :: VersionControlSystem , repoLoom :: Maybe LocalURI , repoClone :: NonEmpty LocalURI + , repoCollaborators :: LocalURI } instance ActivityPub Repo where @@ -653,16 +655,19 @@ instance ActivityPub Repo where <*> o .: "versionControlSystem" <*> withAuthorityMaybeO h (o .:? "sendPatchesTo") <*> (traverse (withAuthorityO h . pure) =<< o .:*+ "cloneUri") - toSeries authority (Repo actor team vcs loom clone) - = toSeries authority actor - <> "team" .= (ObjURI authority <$> team) + <*> withAuthorityO h (o .: "collaborators") + toSeries h (Repo actor team vcs loom clone collabs) + = toSeries h actor + <> "team" .= (ObjURI h <$> team) <> "versionControlSystem" .= vcs - <> "sendPatchesTo" .=? (ObjURI authority <$> loom) - <> "cloneUri" .=*+ (ObjURI authority <$> clone) + <> "sendPatchesTo" .=? (ObjURI h <$> loom) + <> "cloneUri" .=*+ (ObjURI h <$> clone) + <> "collaborators" .= ObjURI h collabs data TicketTracker u = TicketTracker { ticketTrackerActor :: Actor u , ticketTrackerTeam :: Maybe LocalURI + , ticketTrackerCollaborators :: LocalURI } instance ActivityPub TicketTracker where @@ -674,9 +679,29 @@ instance ActivityPub TicketTracker where fmap (h,) $ TicketTracker a <$> withAuthorityMaybeO h (o .:|? "team") - toSeries authority (TicketTracker actor team) - = toSeries authority actor - <> "team" .= (ObjURI authority <$> team) + <*> withAuthorityO h (o .: "collaborators") + toSeries h (TicketTracker actor team collabs) + = toSeries h actor + <> "team" .= (ObjURI h <$> team) + <> "collaborators" .= ObjURI h collabs + +data PatchTracker u = PatchTracker + { patchTrackerActor :: Actor u + , patchTrackerCollaborators :: LocalURI + } + +instance ActivityPub PatchTracker where + jsonldContext _ = [as2Context, secContext, forgeContext] + parseObject o = do + (h, a) <- parseObject o + unless (actorType (actorDetail a) == ActorTypePatchTracker) $ + fail "Actor type isn't PatchTracker" + fmap (h,) $ + PatchTracker a + <$> withAuthorityO h (o .: "collaborators") + toSeries h (PatchTracker actor collabs) + = toSeries h actor + <> "collaborators" .= ObjURI h collabs data CollectionType = CollectionTypeUnordered | CollectionTypeOrdered diff --git a/templates/deck/widget/nav.hamlet b/templates/deck/widget/nav.hamlet index 9af86d7..dcc3ad2 100644 --- a/templates/deck/widget/nav.hamlet +++ b/templates/deck/widget/nav.hamlet @@ -1,6 +1,6 @@ $# This file is part of Vervis. $# -$# Written in 2019, 2022 by fr33domlover . +$# Written in 2019, 2022, 2023 by fr33domlover . $# $# ♡ Copying is an act of love. Please copy, reuse and share. $# diff --git a/templates/loom/widget/nav.hamlet b/templates/loom/widget/nav.hamlet index 6681125..8146542 100644 --- a/templates/loom/widget/nav.hamlet +++ b/templates/loom/widget/nav.hamlet @@ -1,6 +1,6 @@ $# This file is part of Vervis. $# -$# Written in 2019, 2022 by fr33domlover . +$# Written in 2019, 2022, 2023 by fr33domlover . $# $# ♡ Copying is an act of love. Please copy, reuse and share. $# @@ -28,10 +28,11 @@ $# . [🐤 Followers] - [🤝 Collaborators] + + [🤝 Collaborators] - [🧩 Merge Requests] + [🥂 Merge Requests] [🗃 Repository] diff --git a/templates/repo/source-darcs.hamlet b/templates/repo/source-darcs.hamlet index 587cfad..48971af 100644 --- a/templates/repo/source-darcs.hamlet +++ b/templates/repo/source-darcs.hamlet @@ -1,6 +1,6 @@ $# This file is part of Vervis. $# -$# Written in 2016, 2018, 2019, 2020, 2022 +$# Written in 2016, 2018, 2019, 2020, 2022, 2023 $# by fr33domlover . $# $# ♡ Copying is an act of love. Please copy, reuse and share. @@ -46,6 +46,7 @@ $# ^{personNavW user} [🐤 Followers] + [🤝 Collaborators] diff --git a/templates/repo/source-git.hamlet b/templates/repo/source-git.hamlet index 6068949..d3c2a19 100644 --- a/templates/repo/source-git.hamlet +++ b/templates/repo/source-git.hamlet @@ -1,6 +1,6 @@ $# This file is part of Vervis. $# -$# Written in 2016, 2018, 2019, 2020, 2022 +$# Written in 2016, 2018, 2019, 2020, 2022, 2023 $# by fr33domlover . $# $# ♡ Copying is an act of love. Please copy, reuse and share. @@ -46,6 +46,7 @@ $# ^{personNavW user} [🐤 Followers] + [🤝 Collaborators]