DB: Allow actors to mark they've just been created by someone

This will be used for sending that someone a grant with Admin access
This commit is contained in:
Pere Lev 2023-06-19 11:38:25 +03:00
parent c838cece7b
commit 0bd2ca8d5d
No known key found for this signature in database
GPG key ID: 5252C5C863E5E57D
5 changed files with 9 additions and 3 deletions

View file

@ -1136,7 +1136,7 @@ createPatchTrackerC (Entity pidUser personUser) senderActor maybeCap localRecips
insertLoom now name msummary obiidCreate repoID = do insertLoom now name msummary obiidCreate repoID = do
actor@(Entity actorID _) <- actor@(Entity actorID _) <-
insertActor now name (fromMaybe "" msummary) insertActor now name (fromMaybe "" msummary) (Just $ personActor personUser)
loomID <- insert Loom loomID <- insert Loom
{ loomNextTicket = 1 { loomNextTicket = 1
, loomActor = actorID , loomActor = actorID
@ -1372,7 +1372,7 @@ createRepositoryC (Entity pidUser personUser) senderActor maybeCap localRecips r
insertRepo now name msummary createID = do insertRepo now name msummary createID = do
actor@(Entity actorID _) <- actor@(Entity actorID _) <-
insertActor now name (fromMaybe "" msummary) insertActor now name (fromMaybe "" msummary) (Just $ personActor personUser)
repoID <- insert Repo repoID <- insert Repo
{ repoVcs = vcs { repoVcs = vcs
, repoProject = Nothing , repoProject = Nothing
@ -1635,6 +1635,7 @@ createTicketTrackerC (Entity pidUser personUser) senderActor maybeCap localRecip
, actorInbox = ibid , actorInbox = ibid
, actorOutbox = obid , actorOutbox = obid
, actorFollowers = fsid , actorFollowers = fsid
, actorJustCreatedBy = Just $ personActor personUser
} }
did <- insert Deck did <- insert Deck
{ deckActor = aid { deckActor = aid

View file

@ -666,6 +666,7 @@ instance AccountDB AccountPersistDB' where
, actorInbox = ibid , actorInbox = ibid
, actorOutbox = obid , actorOutbox = obid
, actorFollowers = fsid , actorFollowers = fsid
, actorJustCreatedBy = Nothing
} }
aid <- insert actor aid <- insert actor
let defTime = UTCTime (ModifiedJulianDay 0) 0 let defTime = UTCTime (ModifiedJulianDay 0) 0

View file

@ -2954,6 +2954,8 @@ changes hLocal ctx =
, removeEntity "Role" , removeEntity "Role"
-- 539 -- 539
, addFieldPrimRequired "Collab" ("RoleAdmin" :: String) "role" , addFieldPrimRequired "Collab" ("RoleAdmin" :: String) "role"
-- 540
, addFieldRefOptional "Actor" Nothing "justCreatedBy" "Actor"
] ]
migrateDB migrateDB

View file

@ -129,7 +129,7 @@ getRemoteActorURI actor = do
(instanceHost inztance) (instanceHost inztance)
(remoteObjectIdent object) (remoteObjectIdent object)
insertActor now name desc = do insertActor now name desc mby = do
ibid <- insert Inbox ibid <- insert Inbox
obid <- insert Outbox obid <- insert Outbox
fsid <- insert FollowerSet fsid <- insert FollowerSet
@ -140,6 +140,7 @@ insertActor now name desc = do
, actorInbox = ibid , actorInbox = ibid
, actorOutbox = obid , actorOutbox = obid
, actorFollowers = fsid , actorFollowers = fsid
, actorJustCreatedBy = mby
} }
actorID <- insert actor actorID <- insert actor
return $ Entity actorID actor return $ Entity actorID actor

View file

@ -118,6 +118,7 @@ Actor
inbox InboxId inbox InboxId
outbox OutboxId outbox OutboxId
followers FollowerSetId followers FollowerSetId
justCreatedBy ActorId Maybe
UniqueActorInbox inbox UniqueActorInbox inbox
UniqueActorOutbox outbox UniqueActorOutbox outbox