From 3519d0efce1306c3ef257f9b6327101ee7bd1dc9 Mon Sep 17 00:00:00 2001 From: Paul Fitzpatrick Date: Mon, 7 Dec 2020 11:22:57 -0500 Subject: [PATCH] (core) attribute Calculate to grist rather than user Summary: when a document is opened, and Calculate results in a change, that change is not attributed to 'grist' rather than to the user's email. Some minor tweaks included to freshen some related dev scripts. Test Plan: added test Reviewers: dsagal Reviewed By: dsagal Differential Revision: https://phab.getgrist.com/D2679 --- app/server/lib/Sharing.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/server/lib/Sharing.ts b/app/server/lib/Sharing.ts index 1274b3ac..9a162935 100644 --- a/app/server/lib/Sharing.ts +++ b/app/server/lib/Sharing.ts @@ -217,6 +217,12 @@ export class Sharing { const isCalculate = (userActions.length === 1 && userActions[0][0] === 'Calculate'); const trivial = isCalculate && sandboxActionBundle.stored.length === 0; + // For Calculate "user" actions, don't attribute any changes to the user who + // happens to have opened the document. + const attribution = { + ...info, + ...isCalculate ? { user: 'grist' } : undefined, + }; const actionNum = trivial ? 0 : (branch === Branch.Shared ? this._actionHistory.getNextHubActionNum() : @@ -226,7 +232,7 @@ export class Sharing { const localActionBundle: LocalActionBundle = { actionNum, // The ActionInfo should go into the envelope that includes all recipients. - info: [findOrAddAllEnvelope(sandboxActionBundle.envelopes), info], + info: [findOrAddAllEnvelope(sandboxActionBundle.envelopes), attribution], envelopes: sandboxActionBundle.envelopes, stored: sandboxActionBundle.stored, calc: sandboxActionBundle.calc,