From 42fc3a15e945c2d02750ebea06db9cc6cdcad3ac Mon Sep 17 00:00:00 2001 From: Kristina Date: Wed, 8 May 2024 21:18:15 +0400 Subject: [PATCH] Fix extra inbox notifications (#5550) Signed-off-by: Kristina Fefelova --- .../DocUpdateMessageObjectValue.svelte | 3 + .../notification-resources/src/index.ts | 69 +++++++++++-------- 2 files changed, 43 insertions(+), 29 deletions(-) diff --git a/plugins/activity-resources/src/components/doc-update-message/DocUpdateMessageObjectValue.svelte b/plugins/activity-resources/src/components/doc-update-message/DocUpdateMessageObjectValue.svelte index a49968390f..346c23a44f 100644 --- a/plugins/activity-resources/src/components/doc-update-message/DocUpdateMessageObjectValue.svelte +++ b/plugins/activity-resources/src/components/doc-update-message/DocUpdateMessageObjectValue.svelte @@ -91,6 +91,9 @@ {/if} {/await} + {#if hasSeparator} + + {/if} {/if} {/if} diff --git a/server-plugins/notification-resources/src/index.ts b/server-plugins/notification-resources/src/index.ts index ecf1a480fa..71b8ac2dea 100644 --- a/server-plugins/notification-resources/src/index.ts +++ b/server-plugins/notification-resources/src/index.ts @@ -14,7 +14,7 @@ // limitations under the License. // -import activity, { ActivityMessage } from '@hcengineering/activity' +import activity, { ActivityMessage, DocUpdateMessage } from '@hcengineering/activity' import chunter, { ChatMessage } from '@hcengineering/chunter' import contact, { Employee, @@ -701,43 +701,54 @@ export async function getNotificationTxes ( cache: Map, Doc> ): Promise { const res: Tx[] = [] - const notifyResult = await isShouldNotifyTx(control, tx, originTx, object, target, params.isOwn, params.isSpace) - - if (notifyResult.allowed) { - await pushActivityInboxNotifications( - originTx, + for (const message of activityMessages) { + const docMessage = message._class === activity.class.DocUpdateMessage ? (message as DocUpdateMessage) : undefined + const notifyResult = await isShouldNotifyTx( control, - res, - target, + tx, + originTx, object, - docNotifyContexts, - activityMessages, - params.shouldUpdateTimestamp, - notifyResult.push, - cache + target, + params.isOwn, + params.isSpace, + docMessage ) - } - if (notifyResult.emails.length === 0) { - return res - } - const acc = await getPersonAccountById(target, control) - if (acc === undefined) { - return res - } - const emp = await getEmployee(acc.person as Ref, control) - if (emp?.active === true) { - for (const type of notifyResult.emails) { - await notifyByEmail( + if (notifyResult.allowed) { + await pushActivityInboxNotifications( + originTx, control, - type._id, + res, + target, object, - originTx.modifiedBy as Ref, - target as Ref + docNotifyContexts, + [message], + params.shouldUpdateTimestamp, + notifyResult.push, + cache ) } - } + if (notifyResult.emails.length === 0) { + continue + } + const acc = await getPersonAccountById(target, control) + if (acc === undefined) { + continue + } + const emp = await getEmployee(acc.person as Ref, control) + if (emp?.active === true) { + for (const type of notifyResult.emails) { + await notifyByEmail( + control, + type._id, + object, + originTx.modifiedBy as Ref, + target as Ref + ) + } + } + } return res }