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

DB: Allow to record the delegator-Grant sent by people to projects/teams

This commit is contained in:
Pere Lev 2023-11-21 20:44:09 +02:00
parent 7517db9619
commit 5d0f707c55
No known key found for this signature in database
GPG key ID: 5252C5C863E5E57D
6 changed files with 163 additions and 7 deletions

View file

@ -0,0 +1,17 @@
CollabDelegLocal
enable CollabEnableId
recip CollabRecipLocalId
grant OutboxItemId
UniqueCollabDelegLocal enable
UniqueCollabDelegLocalRecip recip
UniqueCollabDelegLocalGrant grant
CollabDelegRemote
enable CollabEnableId
recip CollabRecipRemoteId
grant RemoteActivityId
UniqueCollabDelegRemote enable
UniqueCollabDelegRemoteRecip recip
UniqueCollabDelegRemoteGrant grant

View file

@ -0,0 +1,91 @@
Inbox
FollowerSet
Outbox
OutboxItem
outbox OutboxId
activity PersistJSONObject
published UTCTime
Actor
name Text
desc Text
createdAt UTCTime
inbox InboxId
outbox OutboxId
followers FollowerSetId
justCreatedBy ActorId Maybe
UniqueActorInbox inbox
UniqueActorOutbox outbox
UniqueActorFollowers followers
Person
username Username
login Text
passphraseHash ByteString
email EmailAddress
verified Bool
verifiedKey Text
verifiedKeyCreated UTCTime
resetPassKey Text
resetPassKeyCreated UTCTime
actor ActorId
-- reviewFollow Bool
UniquePersonUsername username
UniquePersonLogin login
UniquePersonEmail email
UniquePersonActor actor
Collab
role Role
CollabTopicProject
collab CollabId
project ProjectId
UniqueCollabTopicProject collab
Project
actor ActorId
create OutboxItemId
UniqueProjectActor actor
UniqueProjectCreate create
CollabTopicGroup
collab CollabId
group GroupId
UniqueCollabTopicGroup collab
Group
actor ActorId
create OutboxItemId
UniqueGroupActor actor
UniqueGroupCreate create
CollabRecipLocal
collab CollabId
person PersonId
UniqueCollabRecipLocal collab
CollabEnable
collab CollabId
grant OutboxItemId
UniqueCollabEnable collab
UniqueCollabEnableGrant grant
CollabDelegLocal
enable CollabEnableId
recip CollabRecipLocalId
grant OutboxItemId
UniqueCollabDelegLocal enable
UniqueCollabDelegLocalRecip recip
UniqueCollabDelegLocalGrant grant

View file

@ -3049,6 +3049,23 @@ changes hLocal ctx =
, addUnique' "Group" "Create" ["create"] , addUnique' "Group" "Create" ["create"]
-- 551 -- 551
, addEntities model_551_group_collab , addEntities model_551_group_collab
-- 552
, addEntities model_552_collab_deleg
-- 553
, unchecked $ lift $ do
collabIDs <-
liftA2 (++)
(map (collabTopicProject553Collab . entityVal) <$> selectList [] [])
(map (collabTopicGroup553Collab . entityVal) <$> selectList [] [])
let doc = persistJSONObjectFromDoc $ Doc hLocal emptyActivity
for_ collabIDs $ \ collabID -> do
e <- getKeyBy $ UniqueCollabEnable553 collabID
r <- getBy $ UniqueCollabRecipLocal553 collabID
for_ e $ \ enableID -> for_ r $ \ (Entity recipID (CollabRecipLocal553 _ personID)) -> do
actorID <- person553Actor <$> getJust personID
outboxID <- actor553Outbox <$> getJust actorID
itemID <- insert $ OutboxItem553 outboxID doc defaultTime
insert_ $ CollabDelegLocal553 enableID recipID itemID
] ]
migrateDB migrateDB

View file

@ -65,6 +65,7 @@ module Vervis.Migration.Entities
, model_541_project , model_541_project
, model_542_component , model_542_component
, model_551_group_collab , model_551_group_collab
, model_552_collab_deleg
) )
where where
@ -252,3 +253,6 @@ model_542_component = $(schema "542_2023-06-26_component")
model_551_group_collab :: [Entity SqlBackend] model_551_group_collab :: [Entity SqlBackend]
model_551_group_collab = $(schema "551_2023-11-21_group_collab") model_551_group_collab = $(schema "551_2023-11-21_group_collab")
model_552_collab_deleg :: [Entity SqlBackend]
model_552_collab_deleg = $(schema "552_2023-11-21_collab_deleg")

View file

@ -531,3 +531,6 @@ makeEntitiesMigration "547"
makeEntitiesMigration "549" makeEntitiesMigration "549"
$(modelFile "migrations/549_2023-11-21_group_create.model") $(modelFile "migrations/549_2023-11-21_group_create.model")
makeEntitiesMigration "553"
$(modelFile "migrations/553_2023-11-21_collab_deleg.model")

View file

@ -682,13 +682,6 @@ CollabTopicGroup
UniqueCollabTopicGroup collab UniqueCollabTopicGroup collab
CollabEnable
collab CollabId
grant OutboxItemId
UniqueCollabEnable collab
UniqueCollabEnableGrant grant
-------------------------------- Collab recipient ---------------------------- -------------------------------- Collab recipient ----------------------------
CollabRecipLocal CollabRecipLocal
@ -721,6 +714,37 @@ CollabRecipRemoteAccept
UniqueCollabRecipRemoteAcceptInvite invite UniqueCollabRecipRemoteAcceptInvite invite
UniqueCollabRecipRemoteAcceptAccept accept UniqueCollabRecipRemoteAcceptAccept accept
-------------------------------- Collab enable -------------------------------
CollabEnable
collab CollabId
grant OutboxItemId
UniqueCollabEnable collab
UniqueCollabEnableGrant grant
-- Component: N/A
-- Project/Team: Witnesses that using the above Grant, the collaborator has
-- sent me a delegator-Grant, which I can now use to extend chains to them
CollabDelegLocal
enable CollabEnableId
recip CollabRecipLocalId
grant OutboxItemId
UniqueCollabDelegLocal enable
UniqueCollabDelegLocalRecip recip
UniqueCollabDelegLocalGrant grant
CollabDelegRemote
enable CollabEnableId
recip CollabRecipRemoteId
grant RemoteActivityId
UniqueCollabDelegRemote enable
UniqueCollabDelegRemoteRecip recip
UniqueCollabDelegRemoteGrant grant
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
-- Components, from project perspective -- Components, from project perspective
------------------------------------------------------------------------------ ------------------------------------------------------------------------------