diff --git a/server-plugins/notification-resources/src/index.ts b/server-plugins/notification-resources/src/index.ts index bf5bb2ac36..7826e9cdd3 100644 --- a/server-plugins/notification-resources/src/index.ts +++ b/server-plugins/notification-resources/src/index.ts @@ -1385,6 +1385,7 @@ async function updateCollaboratorDoc ( if (collabsInfo.added.length > 0) { 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) { @@ -1602,6 +1603,7 @@ async function updateCollaborators ( if (toAdd.length > 0) { res.push(createPushCollaboratorsTx(control, objectId, objectClass, objectSpace, toAdd)) + res.push(...(await pushCollaboratorsToPublicSpace(control, doc, toAdd, cache))) } if (removedCollaborators.length > 0) { diff --git a/server-plugins/time-resources/package.json b/server-plugins/time-resources/package.json index 60560cd955..d82b8a68a6 100644 --- a/server-plugins/time-resources/package.json +++ b/server-plugins/time-resources/package.json @@ -37,6 +37,7 @@ "@types/jest": "^29.5.5" }, "dependencies": { + "@hcengineering/analytics": "^0.6.0", "@hcengineering/contact": "^0.6.24", "@hcengineering/core": "^0.6.32", "@hcengineering/notification": "^0.6.23", diff --git a/server-plugins/time-resources/src/index.ts b/server-plugins/time-resources/src/index.ts index 95f20bb39d..9b5703c8a4 100644 --- a/server-plugins/time-resources/src/index.ts +++ b/server-plugins/time-resources/src/index.ts @@ -13,6 +13,7 @@ // limitations under the License. // +import { Analytics } from '@hcengineering/analytics' import contact, { Employee, Person, PersonAccount } from '@hcengineering/contact' import core, { AttachedData, @@ -29,7 +30,8 @@ import core, { TxFactory, TxProcessor, TxUpdateDoc, - toIdMap + toIdMap, + Space } from '@hcengineering/core' import notification, { CommonInboxNotification } from '@hcengineering/notification' 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[]> { const hierarchy = control.hierarchy + for (const tx of txes) { const createTx = tx as TxCreateDoc<ToDo> @@ -256,6 +259,25 @@ export async function OnToDoCreate (txes: TxCUD<Doc>[], control: TriggerControl) 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 = ( await control.findAll( control.ctx,