Fix extra inbox notifications (#5550)

Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
Kristina 2024-05-08 21:18:15 +04:00 committed by GitHub
parent a8c91993de
commit 42fc3a15e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 43 additions and 29 deletions

View File

@ -91,6 +91,9 @@
{/if} {/if}
</span> </span>
{/await} {/await}
{#if hasSeparator}
<span class="ml-1" />
{/if}
{/if} {/if}
{/if} {/if}

View File

@ -14,7 +14,7 @@
// limitations under the License. // limitations under the License.
// //
import activity, { ActivityMessage } from '@hcengineering/activity' import activity, { ActivityMessage, DocUpdateMessage } from '@hcengineering/activity'
import chunter, { ChatMessage } from '@hcengineering/chunter' import chunter, { ChatMessage } from '@hcengineering/chunter'
import contact, { import contact, {
Employee, Employee,
@ -701,43 +701,54 @@ export async function getNotificationTxes (
cache: Map<Ref<Doc>, Doc> cache: Map<Ref<Doc>, Doc>
): Promise<Tx[]> { ): Promise<Tx[]> {
const res: Tx[] = [] const res: Tx[] = []
const notifyResult = await isShouldNotifyTx(control, tx, originTx, object, target, params.isOwn, params.isSpace) for (const message of activityMessages) {
const docMessage = message._class === activity.class.DocUpdateMessage ? (message as DocUpdateMessage) : undefined
if (notifyResult.allowed) { const notifyResult = await isShouldNotifyTx(
await pushActivityInboxNotifications(
originTx,
control, control,
res, tx,
target, originTx,
object, object,
docNotifyContexts, target,
activityMessages, params.isOwn,
params.shouldUpdateTimestamp, params.isSpace,
notifyResult.push, docMessage
cache
) )
}
if (notifyResult.emails.length === 0) { if (notifyResult.allowed) {
return res await pushActivityInboxNotifications(
} originTx,
const acc = await getPersonAccountById(target, control)
if (acc === undefined) {
return res
}
const emp = await getEmployee(acc.person as Ref<Employee>, control)
if (emp?.active === true) {
for (const type of notifyResult.emails) {
await notifyByEmail(
control, control,
type._id, res,
target,
object, object,
originTx.modifiedBy as Ref<PersonAccount>, docNotifyContexts,
target as Ref<PersonAccount> [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<Employee>, control)
if (emp?.active === true) {
for (const type of notifyResult.emails) {
await notifyByEmail(
control,
type._id,
object,
originTx.modifiedBy as Ref<PersonAccount>,
target as Ref<PersonAccount>
)
}
}
}
return res return res
} }