From d3e2436ac4172f5ca56063ea3fe9ffdd671edce8 Mon Sep 17 00:00:00 2001 From: Kristina Date: Mon, 18 Mar 2024 12:39:24 +0400 Subject: [PATCH] Fix mention email notifictions (#5005) Signed-off-by: Kristina Fefelova --- .../activity-resources/src/references.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/server-plugins/activity-resources/src/references.ts b/server-plugins/activity-resources/src/references.ts index 72c4e52c2d..bac00b5aba 100644 --- a/server-plugins/activity-resources/src/references.ts +++ b/server-plugins/activity-resources/src/references.ts @@ -56,10 +56,6 @@ export async function getPersonNotificationTxes ( space: Ref, originTx: TxCUD ): Promise { - if (reference.attachedTo === senderId) { - return [] - } - const receiver = ( await control.modelDb.findAll( contact.class.PersonAccount, @@ -74,6 +70,10 @@ export async function getPersonNotificationTxes ( return [] } + if (receiver._id === senderId) { + return [] + } + const isAvailable = await isSpaceAvailable(receiver, space, control) if (!isAvailable) { @@ -87,10 +87,6 @@ export async function getPersonNotificationTxes ( res.push(collaboratorsTx) } - if (await isReferenceAlreadyNotified(reference, receiver._id, control)) { - return res - } - const doc = (await control.findAll(reference.srcDocClass, { _id: reference.srcDocId }))[0] if (doc === undefined) { @@ -103,6 +99,11 @@ export async function getPersonNotificationTxes ( } const notifyResult = await shouldNotifyCommon(control, receiver._id, notification.ids.MentionCommonNotificationType) + + if (await isReferenceAlreadyNotified(reference, receiver._id, control)) { + notifyResult.allowed = false + } + const texes = await getCommonNotificationTxes( control, doc,