diff --git a/migrations/565_2023-12-09_collab_permit.model b/migrations/565_2023-12-09_collab_permit.model new file mode 100644 index 0000000..c8a2f97 --- /dev/null +++ b/migrations/565_2023-12-09_collab_permit.model @@ -0,0 +1,300 @@ +Repo +Deck +Loom +Project +Group +RemoteActor +RemoteActivity +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 + +CollabFulfillsLocalTopicCreation + collab CollabId + + UniqueCollabFulfillsLocalTopicCreation collab + +CollabFulfillsInvite + collab CollabId + accept OutboxItemId + + UniqueCollabFulfillsInvite collab + UniqueCollabFulfillsInviteAccept accept + +CollabInviterLocal + collab CollabFulfillsInviteId + invite OutboxItemId + + UniqueCollabInviterLocal collab + UniqueCollabInviterLocalInvite invite + +CollabInviterRemote + collab CollabFulfillsInviteId + actor RemoteActorId + invite RemoteActivityId + + UniqueCollabInviterRemote collab + UniqueCollabInviterRemoteInvite invite + +CollabFulfillsJoin + collab CollabId + + UniqueCollabFulfillsJoin collab + +CollabApproverLocal + collab CollabFulfillsJoinId + accept OutboxItemId + + UniqueCollabApproverLocal collab + UniqueCollabApproverLocalAccept accept + +CollabApproverRemote + collab CollabFulfillsJoinId + actor RemoteActorId + accept RemoteActivityId + + UniqueCollabApproverRemote collab + UniqueCollabApproverRemoteAccept accept + +CollabRecipLocalJoin + collab CollabRecipLocalId + fulfills CollabFulfillsJoinId + join OutboxItemId + + UniqueCollabRecipLocalJoinCollab collab + UniqueCollabRecipLocalJoinFulfills fulfills + UniqueCollabRecipLocalJoinJoin join + +CollabTopicRepo + collab CollabId + repo RepoId + + UniqueCollabTopicRepo collab + +CollabTopicDeck + collab CollabId + deck DeckId + + UniqueCollabTopicDeck collab + +CollabTopicLoom + collab CollabId + loom LoomId + + UniqueCollabTopicLoom collab + +CollabTopicProject + collab CollabId + project ProjectId + + UniqueCollabTopicProject collab + +CollabTopicGroup + collab CollabId + group GroupId + + UniqueCollabTopicGroup collab + +CollabRecipLocal + collab CollabId + person PersonId + + UniqueCollabRecipLocal collab + +CollabRecipLocalAccept + collab CollabRecipLocalId + invite CollabFulfillsInviteId + accept OutboxItemId + + UniqueCollabRecipLocalAcceptCollab collab + UniqueCollabRecipLocalAcceptInvite invite + UniqueCollabRecipLocalAcceptAccept accept + +CollabEnable + collab CollabId + grant OutboxItemId + + UniqueCollabEnable collab + UniqueCollabEnableGrant grant + +CollabDelegLocal + enable CollabEnableId + recip CollabRecipLocalId + grant OutboxItemId + + UniqueCollabDelegLocal enable + UniqueCollabDelegLocalRecip recip + UniqueCollabDelegLocalGrant grant + +Permit + person PersonId + role Role + +PermitTopicLocal + permit PermitId + + UniquePermitTopicLocal permit + +PermitTopicRepo + permit PermitTopicLocalId + repo RepoId + + UniquePermitTopicRepo permit + +PermitTopicDeck + permit PermitTopicLocalId + deck DeckId + + UniquePermitTopicDeck permit + +PermitTopicLoom + permit PermitTopicLocalId + loom LoomId + + UniquePermitTopicLoom permit + +PermitTopicProject + permit PermitTopicLocalId + project ProjectId + + UniquePermitTopicProject permit + +PermitTopicGroup + permit PermitTopicLocalId + group GroupId + + UniquePermitTopicGroup permit + +PermitTopicRemote + permit PermitId + actor RemoteActorId + + UniquePermitTopicRemote permit + +PermitFulfillsTopicCreation + permit PermitId + + UniquePermitFulfillsTopicCreation permit + +PermitFulfillsInvite + permit PermitId + + UniquePermitFulfillsInvite permit + +PermitFulfillsJoin + permit PermitId + + UniquePermitFulfillsJoin permit + +PermitPersonGesture + permit PermitId + activity OutboxItemId + + UniquePermitPersonGesture permit + UniquePermitPersonGestureActivity activity + +PermitTopicGestureLocal + fulfills PermitFulfillsInviteId + invite OutboxItemId + + UniquePermitTopicGestureLocal fulfills + UniquePermitTopicGestureLocalInvite invite + +PermitTopicGestureRemote + fulfills PermitFulfillsInviteId + actor RemoteActorId + invite RemoteActivityId + + UniquePermitTopicGestureRemote fulfills + UniquePermitTopicGestureRemoteInvite invite + +PermitTopicAcceptLocal + fulfills PermitFulfillsInviteId + topic PermitTopicLocalId + accept OutboxItemId + + UniquePermitTopicAcceptLocal fulfills + UniquePermitTopicAcceptLocalTopic topic + UniquePermitTopicAcceptLocalAccept accept + +PermitTopicEnableLocal + permit PermitPersonGestureId + topic PermitTopicLocalId + grant OutboxItemId + + UniquePermitTopicEnableLocal permit + UniquePermitTopicEnableLocalTopic topic + UniquePermitTopicEnableLocalGrant grant + +PermitPersonSendDelegator + permit PermitPersonGestureId + grant OutboxItemId + + UniquePermitPersonSendDelegator permit + UniquePermitPersonSendDelegatorGrant grant + +PermitTopicExtendLocal + permit PermitPersonSendDelegatorId + topic PermitTopicEnableLocalId + grant OutboxItemId + + UniquePermitTopicExtendLocalGrant grant + +Component + project ProjectId + role Role + +ComponentEnable + component ComponentId + grant OutboxItemId + + UniqueComponentEnable component + UniqueComponentEnableGrant grant + +ComponentFurtherLocal + component ComponentEnableId + collab CollabDelegLocalId + grant OutboxItemId + + UniqueComponentFurtherLocal component collab + UniqueComponentFurtherLocalGrant grant diff --git a/src/Vervis/Migration.hs b/src/Vervis/Migration.hs index 97dd4ce..ed10521 100644 --- a/src/Vervis/Migration.hs +++ b/src/Vervis/Migration.hs @@ -3121,6 +3121,81 @@ changes hLocal ctx = , addUnique' "ComponentFurtherRemote" "" ["component", "collab"] -- 564 , addEntities model_564_permit + -- 565 + , removeUnique' "PermitTopicExtendLocal" "" + -- 566 + , removeUnique' "PermitTopicExtendLocal" "Topic" + -- 567 + , removeUnique' "PermitTopicExtendRemote" "" + -- 568 + , removeUnique' "PermitTopicExtendRemote" "Topic" + -- 569 + , unchecked $ lift $ do + recips <- selectList [] [] + for_ recips $ \ (Entity recipID (CollabRecipLocal565 collabID personID)) -> do + Collab565 role <- getJust collabID + permitID <- insert $ Permit565 personID role + topicID <- insert $ PermitTopicLocal565 permitID + + mr <- getValBy $ UniqueCollabTopicRepo565 collabID + for_ mr $ \ (CollabTopicRepo565 _ repoID) -> + insert_ $ PermitTopicRepo565 topicID repoID + md <- getValBy $ UniqueCollabTopicDeck565 collabID + for_ md $ \ (CollabTopicDeck565 _ deckID) -> + insert_ $ PermitTopicDeck565 topicID deckID + ml <- getValBy $ UniqueCollabTopicLoom565 collabID + for_ ml $ \ (CollabTopicLoom565 _ loomID) -> + insert_ $ PermitTopicLoom565 topicID loomID + mj <- getValBy $ UniqueCollabTopicProject565 collabID + for_ mj $ \ (CollabTopicProject565 _ projectID) -> + insert_ $ PermitTopicProject565 topicID projectID + mg <- getValBy $ UniqueCollabTopicGroup565 collabID + for_ mg $ \ (CollabTopicGroup565 _ groupID) -> + insert_ $ PermitTopicGroup565 topicID groupID + + fc <- getKeyBy $ UniqueCollabFulfillsLocalTopicCreation565 collabID + g1 <- for fc $ \ fulfillsID -> do + insert_ $ PermitFulfillsTopicCreation565 permitID + actorID <- person565Actor <$> getJust personID + outboxID <- actor565Outbox <$> getJust actorID + let doc = persistJSONObjectFromDoc $ Doc hLocal emptyActivity + createID <- insert $ OutboxItem565 outboxID doc defaultTime + insert $ PermitPersonGesture565 permitID createID + + fi <- getBy $ UniqueCollabFulfillsInvite565 collabID + g2 <- for fi $ \ (Entity fulfillsID (CollabFulfillsInvite565 _ acceptID)) -> do + pfi <- insert $ PermitFulfillsInvite565 permitID + l <- getValBy $ UniqueCollabInviterLocal565 fulfillsID + for_ l $ \ (CollabInviterLocal565 _ inviteID) -> + insert_ $ PermitTopicGestureLocal565 pfi inviteID + r <- getValBy $ UniqueCollabInviterRemote565 fulfillsID + for_ r $ \ (CollabInviterRemote565 _ actorID inviteID) -> + insert_ $ PermitTopicGestureRemote565 pfi actorID inviteID + insert_ $ PermitTopicAcceptLocal565 pfi topicID acceptID + a <- getValBy $ UniqueCollabRecipLocalAcceptCollab565 recipID + for a $ \ (CollabRecipLocalAccept565 _ _ acceptID) -> + insert $ PermitPersonGesture565 permitID acceptID + + fj <- getKeyBy $ UniqueCollabFulfillsJoin565 collabID + g3 <- for fj $ \ fulfillsID -> do + CollabRecipLocalJoin565 _ _ joinID <- getValByJust $ UniqueCollabRecipLocalJoinCollab565 recipID + insert $ PermitPersonGesture565 permitID joinID + + me <- getValBy $ UniqueCollabEnable565 collabID + for_ (liftA2 (,) me (g1 <|> join g2 <|> g3)) $ \ (CollabEnable565 _ grantID, gestureID) -> do + enableID <- insert $ PermitTopicEnableLocal565 gestureID topicID grantID + d <- getBy $ UniqueCollabDelegLocalRecip565 recipID + for_ d $ \ (Entity cdl (CollabDelegLocal565 _ _ delegID)) -> do + sendID <- insert $ PermitPersonSendDelegator565 gestureID delegID + for_ mj $ \ (CollabTopicProject565 _ projectID) -> do + gs <- E.select $ E.from $ \ (enable `E.InnerJoin` comp `E.InnerJoin` further) -> do + E.on $ enable E.^. ComponentEnable565Id E.==. further E.^. ComponentFurtherLocal565Component + E.on $ enable E.^. ComponentEnable565Component E.==. comp E.^. Component565Id + E.where_ $ + comp E.^. Component565Project E.==. E.val projectID E.&&. + further E.^. ComponentFurtherLocal565Collab E.==. E.val cdl + return $ further E.^. ComponentFurtherLocal565Grant + insertMany_ $ map (PermitTopicExtendLocal565 sendID enableID . E.unValue) gs ] migrateDB diff --git a/src/Vervis/Migration/Model.hs b/src/Vervis/Migration/Model.hs index e713717..bda0e4f 100644 --- a/src/Vervis/Migration/Model.hs +++ b/src/Vervis/Migration/Model.hs @@ -537,3 +537,6 @@ makeEntitiesMigration "553" makeEntitiesMigration "554" $(modelFile "migrations/554_2023-11-21_further_local_deleg.model") + +makeEntitiesMigration "565" + $(modelFile "migrations/565_2023-12-09_collab_permit.model") diff --git a/th/models b/th/models index 4da41c9..d99f88c 100644 --- a/th/models +++ b/th/models @@ -920,8 +920,6 @@ PermitTopicExtendLocal topic PermitTopicEnableLocalId grant OutboxItemId - UniquePermitTopicExtendLocal permit - UniquePermitTopicExtendLocalTopic topic UniquePermitTopicExtendLocalGrant grant PermitTopicExtendRemote @@ -929,8 +927,6 @@ PermitTopicExtendRemote topic PermitTopicEnableRemoteId grant RemoteActivityId - UniquePermitTopicExtendRemote permit - UniquePermitTopicExtendRemoteTopic topic UniquePermitTopicExtendRemoteGrant grant ------------------------------------------------------------------------------