Fix remove project (#7941)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov
2025-02-06 12:41:36 +07:00
committed by GitHub
parent dad177e61d
commit 997d910821
9 changed files with 90 additions and 52 deletions
+24 -1
View File
@@ -36,7 +36,7 @@ import { getMetadata, IntlString } from '@hcengineering/platform'
import serverCore, { TriggerControl } from '@hcengineering/server-core'
import { NOTIFICATION_BODY_SIZE } from '@hcengineering/server-notification'
import { stripTags } from '@hcengineering/text-core'
import tracker, { Component, Issue, IssueParentInfo, TimeSpendReport, trackerId } from '@hcengineering/tracker'
import tracker, { Component, Issue, IssueParentInfo, Project, TimeSpendReport, trackerId } from '@hcengineering/tracker'
import { workbenchId } from '@hcengineering/workbench'
async function updateSubIssues (
@@ -151,6 +151,28 @@ export async function getIssueNotificationContent (
}
}
/**
* @public
*/
export async function OnProjectRemove (txes: Tx[], control: TriggerControl): Promise<Tx[]> {
const result: Tx[] = []
for (const tx of txes) {
const ctx = tx as TxRemoveDoc<Project>
const classes = [tracker.class.Issue, tracker.class.Component, tracker.class.Milestone, tracker.class.IssueTemplate]
for (const cls of classes) {
const docs = await control.findAll(control.ctx, cls, { space: ctx.objectId })
for (const doc of docs) {
const tx = control.txFactory.createTxRemoveDoc(cls, doc.space, doc._id)
result.push(tx)
}
}
}
control.ctx.contextData.broadcast.targets.projectRemove = (it) => {
return []
}
return result
}
/**
* @public
*/
@@ -540,6 +562,7 @@ export default async () => ({
},
trigger: {
OnIssueUpdate,
OnProjectRemove,
OnComponentRemove,
OnWorkspaceOwnerAdded
}