Skip to content

Commit

Permalink
Fix double tx apply with needResult true (#6585)
Browse files Browse the repository at this point in the history
Signed-off-by: Kristina Fefelova <[email protected]>
  • Loading branch information
kristina-fefelova committed Sep 16, 2024
1 parent 9583f57 commit ec6b6fb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions server-plugins/activity-resources/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 []
}

Expand Down
4 changes: 3 additions & 1 deletion server/core/src/triggers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit ec6b6fb

Please sign in to comment.