Fix todo notifications from unavailable space (#7850)

This commit is contained in:
Kristina 2025-01-31 15:14:23 +04:00 committed by GitHub
parent 47d8b19702
commit f112f63d1c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 26 additions and 1 deletions

View File

@ -1385,6 +1385,7 @@ async function updateCollaboratorDoc (
if (collabsInfo.added.length > 0) { if (collabsInfo.added.length > 0) {
res.push(createPushCollaboratorsTx(control, tx.objectId, tx.objectClass, tx.objectSpace, collabsInfo.added)) res.push(createPushCollaboratorsTx(control, tx.objectId, tx.objectClass, tx.objectSpace, collabsInfo.added))
res.push(...(await pushCollaboratorsToPublicSpace(control, doc, collabsInfo.added, cache)))
} }
if (collabsInfo.removed.length > 0) { if (collabsInfo.removed.length > 0) {
@ -1602,6 +1603,7 @@ async function updateCollaborators (
if (toAdd.length > 0) { if (toAdd.length > 0) {
res.push(createPushCollaboratorsTx(control, objectId, objectClass, objectSpace, toAdd)) res.push(createPushCollaboratorsTx(control, objectId, objectClass, objectSpace, toAdd))
res.push(...(await pushCollaboratorsToPublicSpace(control, doc, toAdd, cache)))
} }
if (removedCollaborators.length > 0) { if (removedCollaborators.length > 0) {

View File

@ -37,6 +37,7 @@
"@types/jest": "^29.5.5" "@types/jest": "^29.5.5"
}, },
"dependencies": { "dependencies": {
"@hcengineering/analytics": "^0.6.0",
"@hcengineering/contact": "^0.6.24", "@hcengineering/contact": "^0.6.24",
"@hcengineering/core": "^0.6.32", "@hcengineering/core": "^0.6.32",
"@hcengineering/notification": "^0.6.23", "@hcengineering/notification": "^0.6.23",

View File

@ -13,6 +13,7 @@
// limitations under the License. // limitations under the License.
// //
import { Analytics } from '@hcengineering/analytics'
import contact, { Employee, Person, PersonAccount } from '@hcengineering/contact' import contact, { Employee, Person, PersonAccount } from '@hcengineering/contact'
import core, { import core, {
AttachedData, AttachedData,
@ -29,7 +30,8 @@ import core, {
TxFactory, TxFactory,
TxProcessor, TxProcessor,
TxUpdateDoc, TxUpdateDoc,
toIdMap toIdMap,
Space
} from '@hcengineering/core' } from '@hcengineering/core'
import notification, { CommonInboxNotification } from '@hcengineering/notification' import notification, { CommonInboxNotification } from '@hcengineering/notification'
import { getResource } from '@hcengineering/platform' import { getResource } from '@hcengineering/platform'
@ -225,6 +227,7 @@ export async function OnToDoRemove (txes: Tx[], control: TriggerControl): Promis
export async function OnToDoCreate (txes: TxCUD<Doc>[], control: TriggerControl): Promise<Tx[]> { export async function OnToDoCreate (txes: TxCUD<Doc>[], control: TriggerControl): Promise<Tx[]> {
const hierarchy = control.hierarchy const hierarchy = control.hierarchy
for (const tx of txes) { for (const tx of txes) {
const createTx = tx as TxCreateDoc<ToDo> const createTx = tx as TxCreateDoc<ToDo>
@ -256,6 +259,25 @@ export async function OnToDoCreate (txes: TxCUD<Doc>[], control: TriggerControl)
continue continue
} }
const objectSpace = hierarchy.isDerived(object._class, core.class.Space)
? (object as Space)
: (await control.findAll<Space>(control.ctx, core.class.Space, { _id: object.space }))[0]
if (objectSpace === undefined) {
control.ctx.error('No space found', { objectId: object._id, objectClass: object._class, space: object.space })
Analytics.handleError(
new Error(`No space found for object ${object._id} of class ${object._class} and space ${object.space}`)
)
continue
}
if (
!hierarchy.isDerived(objectSpace._class, core.class.SystemSpace) &&
!objectSpace.members.includes(account[0]._id)
) {
continue
}
const person = ( const person = (
await control.findAll( await control.findAll(
control.ctx, control.ctx,