From 0bd2ca8d5d4b9a03dcda925d5f0686a34c30f9e4 Mon Sep 17 00:00:00 2001 From: Pere Lev Date: Mon, 19 Jun 2023 11:38:25 +0300 Subject: [PATCH] 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 --- src/Vervis/API.hs | 5 +++-- src/Vervis/Foundation.hs | 1 + src/Vervis/Migration.hs | 2 ++ src/Vervis/Persist/Actor.hs | 3 ++- th/models | 1 + 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Vervis/API.hs b/src/Vervis/API.hs index bb443a3..4fc0465 100644 --- a/src/Vervis/API.hs +++ b/src/Vervis/API.hs @@ -1136,7 +1136,7 @@ createPatchTrackerC (Entity pidUser personUser) senderActor maybeCap localRecips insertLoom now name msummary obiidCreate repoID = do actor@(Entity actorID _) <- - insertActor now name (fromMaybe "" msummary) + insertActor now name (fromMaybe "" msummary) (Just $ personActor personUser) loomID <- insert Loom { loomNextTicket = 1 , loomActor = actorID @@ -1372,7 +1372,7 @@ createRepositoryC (Entity pidUser personUser) senderActor maybeCap localRecips r insertRepo now name msummary createID = do actor@(Entity actorID _) <- - insertActor now name (fromMaybe "" msummary) + insertActor now name (fromMaybe "" msummary) (Just $ personActor personUser) repoID <- insert Repo { repoVcs = vcs , repoProject = Nothing @@ -1635,6 +1635,7 @@ createTicketTrackerC (Entity pidUser personUser) senderActor maybeCap localRecip , actorInbox = ibid , actorOutbox = obid , actorFollowers = fsid + , actorJustCreatedBy = Just $ personActor personUser } did <- insert Deck { deckActor = aid diff --git a/src/Vervis/Foundation.hs b/src/Vervis/Foundation.hs index b3de164..7b38726 100644 --- a/src/Vervis/Foundation.hs +++ b/src/Vervis/Foundation.hs @@ -666,6 +666,7 @@ instance AccountDB AccountPersistDB' where , actorInbox = ibid , actorOutbox = obid , actorFollowers = fsid + , actorJustCreatedBy = Nothing } aid <- insert actor let defTime = UTCTime (ModifiedJulianDay 0) 0 diff --git a/src/Vervis/Migration.hs b/src/Vervis/Migration.hs index 8b9000c..08e4cd6 100644 --- a/src/Vervis/Migration.hs +++ b/src/Vervis/Migration.hs @@ -2954,6 +2954,8 @@ changes hLocal ctx = , removeEntity "Role" -- 539 , addFieldPrimRequired "Collab" ("RoleAdmin" :: String) "role" + -- 540 + , addFieldRefOptional "Actor" Nothing "justCreatedBy" "Actor" ] migrateDB diff --git a/src/Vervis/Persist/Actor.hs b/src/Vervis/Persist/Actor.hs index 30e8776..eccf518 100644 --- a/src/Vervis/Persist/Actor.hs +++ b/src/Vervis/Persist/Actor.hs @@ -129,7 +129,7 @@ getRemoteActorURI actor = do (instanceHost inztance) (remoteObjectIdent object) -insertActor now name desc = do +insertActor now name desc mby = do ibid <- insert Inbox obid <- insert Outbox fsid <- insert FollowerSet @@ -140,6 +140,7 @@ insertActor now name desc = do , actorInbox = ibid , actorOutbox = obid , actorFollowers = fsid + , actorJustCreatedBy = mby } actorID <- insert actor return $ Entity actorID actor diff --git a/th/models b/th/models index 306238c..ff1e379 100644 --- a/th/models +++ b/th/models @@ -118,6 +118,7 @@ Actor inbox InboxId outbox OutboxId followers FollowerSetId + justCreatedBy ActorId Maybe UniqueActorInbox inbox UniqueActorOutbox outbox