Files
wekan/server/lib/syncActivation.js
Lauri Ojansivu 24536f6cbd Keep Sync's rule, notification and webhook effects off unless enabled.
Maintainer decision of 2026-09-30: running rules, notifications and
webhooks for changes that Sync makes is off by default. A board opts in
with syncEffectsEnabled, and scheduled runs additionally need the new
instance flag enableSyncCronEffects, so an upgrade changes nothing on
its own. Every stored-effect stage (rules, rule email and archive,
notifications, webhooks) now requires its caller to name the trigger,
manual or scheduled, and checks both switches inside its guard with the
board it re-read, so whatever later wires Sync to these stages cannot
skip them. The switches have no interface yet: the stages are not
called by Sync until the History coordination they wait on is done, and
a toggle that does nothing would mislead.

tests/syncActivation.test.cjs pins the decision, the defaults and that
each stage checks it; the full-app suite refuses a missing trigger, a
board that has not opted in and a scheduled run without the instance
switch, writing nothing, then succeeds once both are on. 560 server
tests pass.

Thanks to xet7 !
2026-09-30 02:00:42 +03:00

22 lines
1.2 KiB
JavaScript

'use strict';
// Sync activation, maintainer decision of 2026-09-30: running rules,
// notifications and webhooks for changes that Sync makes is OFF by default.
// A board administrator enables it per board (board.syncEffectsEnabled) and an
// instance administrator enables it for scheduled runs separately (Admin
// Panel flag enableSyncCronEffects), so an upgrade changes nothing on its own.
//
// Every stored-effect stage checks this in its guard, before and during work,
// so whatever later wires manual or scheduled Sync to these stages cannot
// skip it: the caller must say which trigger it is, and there is no default.
const TRIGGERS = ['manual', 'scheduled'];
function validateSyncTrigger(trigger) {
if (!TRIGGERS.includes(trigger)) throw new Error('sync-activation-trigger-required');
return trigger;
}
function assertSyncActivation({ board, trigger, flags }) {
validateSyncTrigger(trigger);
if (!board || board.syncEffectsEnabled !== true) throw new Error('sync-effects-not-enabled');
if (trigger === 'scheduled' && flags?.enableSyncCronEffects !== true) throw new Error('sync-cron-effects-not-enabled');
}
module.exports = { validateSyncTrigger, assertSyncActivation, SYNC_TRIGGERS: TRIGGERS };