1
0
Fork 0
mirror of https://code.naskya.net/repos/ndqEd synced 2025-03-20 15:14:54 +09:00

Switch to new actor layout

This is such a huge patch, it's probably impossible to tell what it does by
looking at the code. One thing is clear: It changes *everything* :P so here's
an overview:

- There are now 5 types of actors, each having its own top-level route
- So projects, repos, etc. are no longer "under" sharers
- Actor routes are now based on their KeyHashid, there are no "idents" anymore,
  i.e. URLs look random and don't contain user or repo names
- No sharers anymore; people and groups are distinct entities not sharing a
  common namespace or anything like that
- Project has been renamed to Deck and it simply means a ticket tracker; repos
  are no longer "under" projects
- In addition to Person, Group, Repo and Deck, there's a new actor type Loom,
  which is a patch tracker; i.e. Repo actors don't manage MRs anymore
- All C2S and S2S is temporarily disabled, because huge changes to the whole
  code are required and I'll do them gradually in the next patches
- Since form-based actions are implemented using C2S, they're disabled as well,
  so Vervis is now essentially read-only
- Some views have been temporarily removed, e.g. repo history and commit view
- A huge set of DB migrations has been added to adapt the DB to these changes;
  I haven't tested them yet on a read DB so there may be errors there; I'll fix
  them in the next patches if I find any (probably going to test on the main
  instance where Vervis itself is hosted...)
- Some modules got tech upgrades, e.g. LocalActor became a higher-kinded type
  and a similar pattern is probably relevant for several other types
- There's an 'Actor' entity in the DB schema now, and all 5 actor types use it
  for common things like inbox and outbox
- Although inbox and outbox are used only by Actor, so essentially could be
  removed, I haven't removed them; that's because I wonder if at some point
  users can have a tree of inboxes much like in email; I don't have an excuse
  for Outbox, but anyway, leaving them as is for now
- Workflows, roles and collaborators are partially removed/unused until I
  figure out a sane federated way to provide these features
- Since repo routes don't contain a "sharer" anymore, SSH URIs are now simpler,
  they already look like user@host/repo regardless of who "controls" that repo
This commit is contained in:
fr33domlover 2022-08-15 13:57:42 +00:00
parent 91b2d36a19
commit 2e72684fd5
94 changed files with 8767 additions and 7728 deletions

View file

@ -451,7 +451,7 @@ instance ActivityPub Actor where
data Repo u = Repo
{ repoActor :: Actor u
, repoTeam :: LocalURI
, repoTeam :: Maybe LocalURI
, repoVcs :: VersionControlSystem
}
@ -463,16 +463,16 @@ instance ActivityPub Repo where
fail "Actor type isn't Repository"
fmap (h,) $
Repo a
<$> withAuthorityO h (o .:| "team")
<$> withAuthorityMaybeO h (o .:|? "team")
<*> o .: "versionControlSystem"
toSeries authority (Repo actor team vcs)
= toSeries authority actor
<> "team" .= ObjURI authority team
<> "team" .= (ObjURI authority <$> team)
<> "versionControlSystem" .= vcs
data TicketTracker u = TicketTracker
{ ticketTrackerActor :: Actor u
, ticketTrackerTeam :: LocalURI
, ticketTrackerTeam :: Maybe LocalURI
}
instance ActivityPub TicketTracker where
@ -483,10 +483,10 @@ instance ActivityPub TicketTracker where
fail "Actor type isn't TicketTracker"
fmap (h,) $
TicketTracker a
<$> withAuthorityO h (o .:| "team")
<$> withAuthorityMaybeO h (o .:|? "team")
toSeries authority (TicketTracker actor team)
= toSeries authority actor
<> "team" .= ObjURI authority team
<> "team" .= (ObjURI authority <$> team)
data CollectionType = CollectionTypeUnordered | CollectionTypeOrdered
@ -1085,7 +1085,7 @@ encodeTicketLocal
data MergeRequest u = MergeRequest
{ mrOrigin :: Maybe (ObjURI u)
, mrTarget :: LocalURI
, mrTarget :: Either LocalURI (Branch u)
, mrBundle :: Either (ObjURI u) (Authority u, Bundle u)
}
@ -1097,12 +1097,16 @@ instance ActivityPub MergeRequest where
unless (typ == ("Offer" :: Text)) $
fail "type isn't Offer"
ObjURI a target <- o .: "target"
target <- o .:+ "target"
let (a, target') =
case target of
Left (ObjURI h lu) -> (h, Left lu)
Right (Doc h branch) -> (h, Right branch)
fmap (a,) $
MergeRequest
<$> o .:? "origin"
<*> pure target
<*> pure target'
<*> (second fromDoc . toEither <$> o .: "object")
where
fromDoc (Doc h v) = (h, v)
@ -1110,7 +1114,7 @@ instance ActivityPub MergeRequest where
toSeries h (MergeRequest morigin target bundle)
= "type" .= ("Offer" :: Text)
<> "origin" .=? morigin
<> "target" .= ObjURI h target
<> "target" .=+ bimap (ObjURI h) (Doc h) target
<> "object" .= fromEither (second (uncurry Doc) bundle)
data Ticket u = Ticket