From ec6b6fb56807c49c0496f7bea147c321c18a1c7b Mon Sep 17 00:00:00 2001 From: Kristina Date: Mon, 16 Sep 2024 16:02:28 +0400 Subject: [PATCH] Fix double tx apply with needResult true (#6585) Signed-off-by: Kristina Fefelova --- server-plugins/activity-resources/src/index.ts | 4 ++-- server/core/src/triggers.ts | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/server-plugins/activity-resources/src/index.ts b/server-plugins/activity-resources/src/index.ts index 3113a7ffaf..1521ea4207 100644 --- a/server-plugins/activity-resources/src/index.ts +++ b/server-plugins/activity-resources/src/index.ts @@ -60,13 +60,13 @@ export async function OnReactionChanged (originTx: Tx, control: TriggerControl): if (innerTx._class === core.class.TxCreateDoc) { const txes = await createReactionNotifications(tx, control) - await control.apply(control.ctx, txes, true) + await control.apply(control.ctx, txes) return [] } if (innerTx._class === core.class.TxRemoveDoc) { const txes = await removeReactionNotifications(tx, control) - await control.apply(control.ctx, txes, true) + await control.apply(control.ctx, txes) return [] } diff --git a/server/core/src/triggers.ts b/server/core/src/triggers.ts index 49a9b90c2c..4caeafeb2a 100644 --- a/server/core/src/triggers.ts +++ b/server/core/src/triggers.ts @@ -99,7 +99,9 @@ export class Triggers { ctx, txFactory: null as any, // Will be set later apply: async (ctx, tx, needResult) => { - apply.push(...tx) + if (needResult !== true) { + apply.push(...tx) + } ctrl.txes.push(...tx) // We need to put them so other triggers could check if similar operation is already performed. return await ctrl.apply(ctx, tx, needResult) }