Skip to content

Commit

Permalink
Discard webhook trigger only on Calculate action #799
Browse files Browse the repository at this point in the history
  • Loading branch information
Florent FAYOLLE committed Jan 3, 2024
1 parent 8593d5c commit 76ade8f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions app/server/lib/Sharing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {ActionHistory, asActionGroup, getActionUndoInfo} from './ActionHistory';
import {ActiveDoc} from './ActiveDoc';
import {makeExceptionalDocSession, OptDocSession} from './DocSession';
import {WorkCoordinator} from './WorkCoordinator';
import {createEmptyActionSummary} from 'app/common/ActionSummary';
import {summarizeAction} from 'app/common/ActionSummarizer';

// Describes the request to apply a UserActionBundle. It includes a Client (so that broadcast
// message can set `.fromSelf` property), and methods to resolve or reject the promise for when
Expand Down Expand Up @@ -247,14 +247,14 @@ export class Sharing {

try {

const isCalculate = (userActions.length === 1 && SYSTEM_ACTIONS.has(userActions[0][0] as string));
const isSystemAction = (userActions.length === 1 && SYSTEM_ACTIONS.has(userActions[0][0] as string));
// `internal` is true if users shouldn't be able to undo the actions. Applies to:
// - Calculate/UpdateCurrentTime because it's not considered as performed by a particular client.
// - Adding attachment metadata when uploading attachments,
// because then the attachment file may get hard-deleted and redo won't work properly.
// - Action was rejected but it had some side effects (e.g. NOW() or UUID() formulas).
const internal =
isCalculate ||
isSystemAction ||
userActions.every(a => a[0] === "AddRecord" && a[1] === "_grist_Attachments") ||
!!failure;

Expand Down Expand Up @@ -306,7 +306,7 @@ export class Sharing {

// If the document has shut down in the meantime, and this was just a "Calculate" action,
// return a trivial result. This is just to reduce noisy warnings in migration tests.
if (this._activeDoc.isShuttingDown && isCalculate) {
if (this._activeDoc.isShuttingDown && isSystemAction) {
return {
actionNum: localActionBundle.actionNum,
retValues: [],
Expand Down Expand Up @@ -337,9 +337,10 @@ export class Sharing {
}
await this._activeDoc.processActionBundle(ownActionBundle);

const isCalculate = userActions.length === 1 && userActions[0][0] === 'Calculate';
const actionSummary = !isCalculate ?
await this._activeDoc.handleTriggers(localActionBundle) :
createEmptyActionSummary();
summarizeAction(localActionBundle);

await this._activeDoc.updateRowCount(sandboxActionBundle.rowCount, docSession);

Expand Down

0 comments on commit 76ade8f

Please sign in to comment.