Skip to content

Commit fd471d3

Browse files
fix(messaging): a member's own "no digest" or "no quiet hours" beats the organization's default (#36326)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"} --> _Requested by **Leehom** · [project thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1X8UqWLrzTYpuat8L5eLdf2c)_ Fixes #35123 Clause-②: no Metadata-protocol: none Ruling: 7073270426 on #35123 (maintainer, verbatim: 「B 没设的项继续跟随组织」), building ruling 6996036362 (「成员自己的选择优先」); interim hook per the seat's answer to fork 7073430021, F1 carried by #36245. ## 维护者速读 - 用户能看到什么变化:成员在“通知设置”页选「不汇总」或清空免打扰时段并保存,从此真的不再收到组织默认的汇总或免打扰;没动过的那一项继续跟随组织,升级当天没有任何人的通知发生变化。 - 为什么做:落实「成员自己的选择优先」,解决成员退不出组织默认汇总和免打扰的问题(本卡已升为 p1)。 - 出错会怎样:最坏情况是某位成员的汇总或免打扰仍跟随组织,或一条旧数据被误当成本人选择;都只影响通知的送达时间,不丢通知,可通过撤回本 PR 恢复原行为。 - 要你做什么:请你审阅、批准并亲手合并。L1 ACCEPT 7076146202,契约 PASS 7076382062(座位 7,head 621aa11);一个不阻塞的问题(一次性转换只应改转换开始前的那批「不汇总」行)和两个可选项另立 #36369 跟进。 ## What changes Ruling 7073270426 (report letter B): a notification preference's `digest` and `quiet_hours` are each **three states in storage**, and one rule decides them. The most specific preference that sets a field decides it. A preference that leaves a field empty decides nothing for that field, so the walk goes on: the person's topic row, then their own wildcard row, then the organization's default, then the built-in default. | State | `digest` | `quiet_hours` | |---|---|---| | not set (follows the next row) | empty | empty | | explicitly off (decides: off) | `none` | `{ "off": true }` | | a value (decides) | `daily` / `weekly` | a window `{ tz?, start, end }` | - **Object definition** (`notification-preference.object.ts`): `digest` loses `defaultValue: 'none'`, so a row nobody chose a digest for stores empty, and a stored `none` is the explicit "send each one right away" its description already promised. Both field helps now state the three states, in all 11 locales. - **Resolver** (`preference-resolver.ts`): `parseDigest` admits `none` as a decision. `parseQuietHours` reads `{ off: true }` as the explicit off, and `off: true` wins over any other key. `resolveDigest` and `resolveQuietHours` stop at the first row that sets the field (`!== undefined`) rather than at the first truthy value. The door (`effectiveFor`) answers a member's explicit off as `{ value: 'none' / null, source: 'own' }`. - **One-time conversion** (`preference-digest-conversion.ts`, wired at `kernel:ready`): every stored `digest = 'none'`, in every organization, becomes empty, ONCE. Before this release a stored `none` never took effect, so no one's effective digest changes at upgrade. **Run-once route:** a `sys_migration` ledger row (`messaging-preference-digest-none-unset`), read and written through the engine, with `DATA_MIGRATION_FLAG_OBJECT` imported from `@objectstack/spec/system` and the id spelled locally. `plugin-auth`'s `membership-backfill-ledger.ts` is the precedent. The row is CLAIMED before the first rewrite, so no later boot runs again, whatever fails mid-pass. Each rewrite is a compare-and-set (`where: { id, digest: 'none' }, multi: true`), so a value written since the read is left alone. With no ledger on the kernel, or a ledger it cannot read, the pass does not run and says so at `warn`. Per-row failures are named at `error` with the fix. ⛔ It is deliberately NOT the every-boot shape of `preference-user-conversion.ts`: after this release a `none` is a real choice, and an every-boot pass would erase it. - **The Notification Settings page** (`myPreferences.ts`, `NotificationSettingsPage.tsx`): "No digest" (不汇总) is always offered and saves `none`. Clearing the quiet-hours window and pressing Save stores `{ off: true }`, never empty. A half-filled window still cannot be saved. The `digestNoOff` and `quietHoursNoClear` notes are removed from all 11 locale bundles. The quiet-hours control (`ui/packages/fields`) is untouched: the page never hands it the marker, because the door answers an explicit off as `null` with `source: 'own'`. - **Docs**: `content/docs/data-modeling/field-types.mdx` states the three states and the rule once. ### Why `{ "off": true }` for "no quiet hours, by choice" (for the contract review) - **A marked value, not `{}`.** `{}` and `null` are what a cleared widget or an API caller writes for each other. One written for the other would silently turn "off" back into "follow the organization". Nothing produces `{ off: true }` by clearing something. - **It stays an object**, so the column's one JSON shape family holds and the existing JSON-string read path (`parseQuietHours` parses strings) covers it unchanged. - **It is inert to the field control.** `ui/packages/fields` `readQuietHours` already reads any unknown key as `unreadable`: it shows the value as stored and never rewrites it unless the person replaces it. So the Setup grid cannot silently drop it. - **It names its meaning.** `off: true` reads as "off" in a raw row, an export or an audit diff, where `{}` reads as "nothing". - **Precedence is declared**: `off: true` wins over any `start` / `end` beside it. Mixing them is not a supported write, but if it happens it reads as the stronger statement. ### Deviations - **Interim owner-side hook, TEMPORARY, carried by #36245** (`preference-digest-unset.ts`, bound in `messaging-service-plugin.ts`). A SQL database created by an earlier release keeps the old physical column default (`digest varchar(255) default 'none'`), and schema sync never retrofits a column default on an existing table. On such a database, an insert that omits `digest` would get `none` from the database, which now means the member's explicit "no digest". The hook writes `digest: null` on every insert that leaves it unset, so the database default never fires. It comes out in the change that lands #36245, and the code comment says so. - ⚠️ **A write that skips engine hooks still stores `none`** on a database that carries the legacy column DEFAULT. That covers raw SQL and a bulk load straight into the table. Such a `none` reads as the person's explicit "no digest" until #36245 lands. - File surface: beyond claim revisions 7073295574 and 7073458517, the diff touches `docs/audits/2026-08-tenant-audit-write-call-sites.counts/services/service-messaging.md`, regenerated by `node scripts/tenant-audit-census.mjs --write` for the three new write call sites (the gate's own fix line). It also touches the 11 `service-messaging` `*.objects.generated.ts` bundles: `en` was regenerated by `check-i18n-bundles.mjs --write`, and the 10 translated helps were extended by hand. `packages/spec/**` is untouched. - Clause-②: no. No published accept set widens or narrows: the `digest` select still accepts the same three values, `quiet_hours` was already free JSON, and no export is added to or removed from the package index (the new modules are internal). The meaning of a stored `none` changes, which the one-time conversion covers. Metadata-protocol: none, because `sys_notification_preference` rows are data, not authored metadata. - After a member's explicit "no quiet hours" (`{ off: true }`), the digest takes its time zone from the next preference row in the walk that holds a quiet-hours window (normally the organization default), so it still flushes at midnight in that zone (for example Europe/Berlin); with no window on any row it stays on UTC (L1 R1 7075548155, fix b, at `621aa11e59`; pinned in `preference-resolver.test.ts` with a UTC control, ablation red then restored). ADR-0030 l.93-94 still reads true: the digest still takes a `quiet_hours.tz`, now from the nearest row that holds a window. ## Tests <details><summary>Pins (service-messaging, app-shell) at 1c5040c</summary> - `preference-resolver.test.ts` (fake engine), new describe "a member's explicit off beats the organization default": - member `none` beats an org `daily` default, and an org `weekly` default (`it.each`); - member `{ off: true }` beats the org window, including when the column holds it as a JSON string; - CONTROL: no member row follows the org default; - CONTROL: a member row with the field `null`, `undefined` or `''` follows the org default, and `{}` is not the off; - a member who sets one field keeps following the org on the other, and follows a later org change; - a topic row's explicit choice beats the member's own wildcard row; - an org default row that is explicitly off is no default; - multi-org: the same person in `org_a` (opted out) and `org_b` (unset): `org_b` keeps the digest. - `preference-digest-three-states.integration.test.ts` (real `ObjectQL` + `SqlDriver` better-sqlite3 FILE database; boot 1 with the legacy object, boot 2 with the new one, same file): - upgraded database: an insert that leaves the digest unset stores `null` (the premise is asserted first: boot 1 stores `none`); an explicit `none` stays `none`; - the conversion rewrites the legacy `none` in `org_a` and `org_b`, including an org default row, leaves `daily` alone, and records `sys_migration` with `{ status: converted, converted: 3, failed: [] }`, with no error logged; - a `none` written after the conversion is still `none` after a second boot (`already-run`), both an updated row and a fresh insert; - with no ledger on the kernel the pass does not run, warns once, and leaves the row as stored; - the door (`effectiveFor`) answers the member's explicit off as `own`, and a member row that leaves both unset follows the org (`default`). - `myPreferences.test.ts` / `NotificationSettingsPage.test.tsx`: "No digest" is offered while an org digest is in force and saves `digest: 'none'`; a cleared window saves `quiet_hours: { off: true }`; a half-filled window cannot be saved. Runs, under the verify lock: - `pnpm --filter @objectstack/service-messaging exec vitest run --maxWorkers=2`: VERDICT command-exit 0, Test Files 80 passed (80), Tests 1075 passed (1075). - `pnpm --filter @objectstack/service-messaging typecheck`: exit 0. - `pnpm --filter @object-ui/app-shell exec vitest run --root ../.. --maxWorkers=2 packages/app-shell/src/console/notification-settings`: Test Files 3 passed (3), Tests 46 passed (46). - `pnpm --dir ui exec vitest run --maxWorkers=2 scripts/`: Test Files 172 passed, 2 skipped (174). </details> <details><summary>Ablations: each pin's subject mutated through scripts/ablation-replace.mjs (WRAP mode, run under the lock), each restored to the HEAD blob with an empty git diff HEAD</summary> | # | Subject mutated | Red | |---|---|---| | A1 | `parseDigest` admits `none` → removed | 5 failed: none beats daily, none beats weekly, topic row, multi-org, door pin | | A2 | `parseQuietHours` `off: true` line deleted | 3 failed: off beats window, JSON-string off, door pin | | A3 | unset read as `none` (`null` / `''` → `'none'`) | 4 failed: CONTROL field-unset, one-field-follows, multi-org, door CONTROL | | A4 | the hook's `data.digest = null` deleted | 1 failed: upgraded database, unset stores null | | A5 | early already-run check removed | stayed GREEN (42/42): the claim's duplicate ledger id re-reads as already-run, so the early check is a second guard, not the pin's subject | | A5b | the claim written under another id (`'ablated-' + startedAt`) | 2 failed: records itself; a none written after the conversion survives a second boot | | A6 | conversion read scoped to `tenantId: 'org_a'` | 1 failed: rewrites every organization's legacy none | | A7 | `quietHoursStored(null)` returns the draft | 2 failed: stored as `{ off: true }` (unit), cleared window saves the off (page) | | A8 | `digestChoices` drops `none` | 3 failed: offered while org digest in force (unit), page offers and saves none, current value none | The service-messaging subjects are imported from `src` by relative path, so no `dist/` was involved; the app-shell subjects likewise. A8's first attempt was NOT MEASURED (lock queue-timeout 99) and was re-run with the result shown. </details> ## Acceptance notes - The page has no "follow the organization again" action for digest and quiet hours. Writing the field empty would do it, but the ruling did not ask for one. The Setup grid can still clear the field. - The plugin's wiring of the hook and the conversion is exercised by `messaging-service-plugin.test.ts`'s boot tests (green), not by a dedicated pin. The pins drive the modules directly. - If the ledger insert fails after the read, the pass does not run, and the next boot tries again. A `none` written between those boots would then be converted. This is logged at `error` with the fix. - Carried by #36369: contract review 7076382062 S1 (the one-time conversion should rewrite only the pre-claim snapshot of `none` rows), plus the optional "follow the organization again" page action and the shared `QUIET_HOURS_OFF` spelling. ## Verification - Read first, by risk: `packages/services/service-messaging/src/preference-digest-conversion.ts` (the run-once claim and the compare-and-set), `packages/services/service-messaging/src/preference-resolver.ts` (`parseDigest` / `parseQuietHours` and the two walks), `packages/services/service-messaging/src/preference-digest-unset.ts` (the temporary hook). - Two minutes: `pnpm --filter @objectstack/service-messaging exec vitest run --maxWorkers=2 src/preference-digest-three-states.integration.test.ts src/preference-resolver.test.ts`, expect 2 files and 42 tests green, including "a none written after the conversion is still none after a second boot". <details><summary>Local gates (dispatch-gates --commands at 1c5040c, 109 commands)</summary> - `node scripts/pm/dispatch-gates.mjs --commands`: 109 derived. At 1c5040c, 105 ran in one pass with each exit code captured before any pipe: all exit 0. Four ran on their own: `pnpm --dir ui exec vitest run scripts/` (under the lock, maxWorkers=2) exit 0, 172 passed and 2 skipped; `pnpm --filter @objectstack/spec run check:skill-examples` exit 0 after building the client-react closure; `pnpm check:type-check-debt` exit 0; `pnpm check:dual-build-cjs-loads` UNRUN. - `--ran` reconciliation: 109 derived, 108 run, 0 NOT-MEASURED, 1 UNRUN (`check:dual-build-cjs-loads`). That is a declared narrowing: its prerequisite is a full `pnpm build` of the monorepo, so the CI Lint and Repo Gates job carries it. - Earlier reds, fixed in this branch: `check:tenant-audit-census` (census regenerated), `check:engine-double-contract` and `check:objectql-double-limit` (the doubles were replaced by a real engine in the integration file). - `node scripts/check-platform-checklist.mjs --changed-from origin/main`: exit 0. `check:i18n`: in sync. - NOT MEASURED: app-shell `type-check`, because the ui closure was not built (the unresolved modules are the `@object-ui/*` packages). The only notification-settings diagnostic is the existing `apiFetch` line, unchanged from origin/main. CI Type Check UI carries it. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01FEkQ5pb2t8Z8C64PkPyVt1)_ <!-- signed: repo:objectstack#4 · os-project-manager · session_01FEkQ5krBqrrgxCYgjXmfbv --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 7acc09b commit fd471d3

36 files changed

Lines changed: 942 additions & 130 deletions
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
'@objectstack/service-messaging': patch
3+
'@object-ui/app-shell': patch
4+
'@object-ui/i18n': patch
5+
---
6+
7+
fix(messaging): a member's own "no digest" or "no quiet hours" now beats the organization's default
8+
9+
Clause-②: no
10+
Metadata-protocol: none
11+
12+
A member who chooses no digest, or clears their quiet hours, now keeps that choice even when the organization's default sets a digest or quiet hours. The organization's default is a default, not a floor. Before this release the member still got the organization's digest and quiet hours.
13+
14+
- **Three states per field.** A notification preference's `digest` and `quiet_hours` are each one of: not set (empty), explicitly off, or a value. The most specific preference that sets the field decides it. A preference that leaves a field empty decides nothing for that field, so it keeps following the next preference: the default for all users, then none. Explicit off is `none` for the digest and `{ "off": true }` for quiet hours. An organization default that is explicitly off is the same as no default. After an explicit "no quiet hours", the member's digest still lands at midnight in the time zone of the organization's quiet-hours window (the next preference that holds one), or UTC when none does.
15+
- **`digest` has no default value any more.** A preference created without a digest stores it empty, so it follows the organization's default. On a database created by an earlier release, the `digest` column still carries the old database default `none`. The messaging service writes an explicit empty digest on every insert that leaves it out, so the database default never applies. A write that skips the platform's engine (raw SQL, a bulk load straight into the table) still stores `none` on such a database. That stored `none` now means "no digest".
16+
- **Stored rows keep their meaning.** On the first start of this release, every stored `digest = 'none'` is rewritten to empty, in every organization, once. The pass is recorded in `sys_migration` (`messaging-preference-digest-none-unset`) and never runs again, so a `none` chosen after the upgrade is kept. A stored `none` never took effect before, so no one's digest changes at upgrade. If you picked "none" by hand in Setup > Notification Preferences to opt out, pick it again after upgrading.
17+
- **The Notification Settings page offers the opt-out.** "No digest" is always offered and saves `none`. Clearing the quiet-hours window and saving stores `{ "off": true }`. The two notes saying these choices were not offered are gone, in all 11 languages.

‎content/docs/data-modeling/field-types.mdx‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1169,7 +1169,14 @@ widgets, so the record form offers choices instead of a bare box:
11691169
|---|---|---|---|
11701170
| `notification-topic` | `topic` (`text`; also on `sys_notification_template`) | a pick-or-type list from `GET /api/v1/messaging/preference-options` | the topic as written, `*` for all |
11711171
| `notification-channel` | `channel` (`text`) | the same list, marking a known channel whose service is not configured | the channel id as written, `*` for all |
1172-
| `quiet-hours` | `quiet_hours` (`json`) | a time-zone picker and two times | `{ tz?, start: 'HH:MM', end: 'HH:MM' }` |
1172+
| `quiet-hours` | `quiet_hours` (`json`) | a time-zone picker and two times | `{ tz?, start: 'HH:MM', end: 'HH:MM' }`, or `{ off: true }` for no quiet hours |
1173+
1174+
A preference's `digest` and `quiet_hours` each have three states. Empty means not set: the next
1175+
preference decides, which is the default for all users and then none. The explicit off is `none`
1176+
for the digest and `{ "off": true }` for quiet hours. Otherwise the field holds a value. For each
1177+
field, the most specific preference that sets it decides, so a person's own "no digest" or "no
1178+
quiet hours" beats the organization's default. The `quiet-hours` widget shows a stored
1179+
`{ "off": true }` as stored and keeps it unless it is replaced.
11731180
11741181
A typed topic or channel the list does not hold is still stored. Like every `widget` value,
11751182
a name no host registers falls back to the type's default input.

‎docs/audits/2026-08-tenant-audit-write-call-sites.counts/services/service-messaging.md‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,24 @@ a row or a number here — fix the code, or the census, and regenerate.
1414

1515
| Measure | Value |
1616
|---|---:|
17-
| Write call sites | 22 |
18-
| Object name statically decidable | 7 |
19-
| Object name chosen at run time | 15 |
17+
| Write call sites | 25 |
18+
| Object name statically decidable | 8 |
19+
| Object name chosen at run time | 17 |
2020
| Object name spelled inline | 0 |
21-
| Object name spelled through a `const` | 7 |
21+
| Object name spelled through a `const` | 8 |
2222
| Object name is an `object: string` parameter | 0 |
23-
| Object name is some other run-time expression | 15 |
24-
| Against a tenancy-enabled object | 2 |
23+
| Object name is some other run-time expression | 17 |
24+
| Against a tenancy-enabled object | 3 |
2525
| Against an object declaring tenancy off | 5 |
26-
| Threading a tenant context | 15 |
26+
| Threading a tenant context | 18 |
2727
| Provably carrying none (options read, no context key) | 0 |
2828
| …and decidably tenancy-enabled | 0 |
2929
| Options argument unreadable | 7 |
3030
| …and decidably tenancy-enabled | 0 |
31-
| Threading a decidably elevated (`isSystem`) context | 1 |
31+
| Threading a decidably elevated (`isSystem`) context | 4 |
3232
| Threading a decidably non-elevated context | 0 |
3333
| Threading a context of undecidable elevation | 21 |
34-
| Receiver carried a readable engine type | 22 |
34+
| Receiver carried a readable engine type | 25 |
3535
| Receiver erased, placed by the object NAME | 0 |
3636
| Receiver erased, placed by an `object: string` PARAMETER | 0 |
3737
| Receiver erased, placed by an `UNTYPED_RECEIVERS` row | 0 |
@@ -55,6 +55,9 @@ a row or a number here — fix the code, or the census, and regenerate.
5555
| `packages/services/service-messaging/src/messaging-service.ts` | `insert` | `RECEIPT_OBJECT` | undecidable | context, elevation undecidable | 1 |
5656
| `packages/services/service-messaging/src/messaging-service.ts` | `update` | `RECEIPT_OBJECT` | undecidable | options unreadable | 1 |
5757
| `packages/services/service-messaging/src/messaging-service.ts` | `insert` | `sys_notification` | enabled | context, elevation undecidable | 1 |
58+
| `packages/services/service-messaging/src/preference-digest-conversion.ts` | `insert` | `DATA_MIGRATION_FLAG_OBJECT` | undecidable | elevated | 1 |
59+
| `packages/services/service-messaging/src/preference-digest-conversion.ts` | `update` | `DATA_MIGRATION_FLAG_OBJECT` | undecidable | elevated | 1 |
60+
| `packages/services/service-messaging/src/preference-digest-conversion.ts` | `update` | `sys_notification_preference` | enabled | elevated | 1 |
5861
| `packages/services/service-messaging/src/preference-user-conversion.ts` | `update` | `sys_notification_preference` | enabled | elevated | 1 |
5962
| `packages/services/service-messaging/src/sql-http-outbox.ts` | `insert` | `this.objectName` | undecidable | context, elevation undecidable | 1 |
6063
| `packages/services/service-messaging/src/sql-http-outbox.ts` | `update` | `this.objectName` | undecidable | context, elevation undecidable | 4 |

‎packages/services/service-messaging/src/messaging-service-plugin.ts‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ import {
4444
import { NotificationTextRenderer, type NotificationTextI18n } from './notification-text.js';
4545
import { installInboxReaderLocale, type InboxReaderLocaleEngine } from './inbox-reader-locale.js';
4646
import { convertWildcardPreferenceUsers } from './preference-user-conversion.js';
47+
import { convertLegacyNoneDigestsOnce } from './preference-digest-conversion.js';
48+
import {
49+
bindPreferenceDigestUnset,
50+
unbindPreferenceDigestUnset,
51+
type PreferenceDigestHookEngine,
52+
} from './preference-digest-unset.js';
4753
import {
4854
InboxMessage,
4955
NotificationReceipt,
@@ -255,6 +261,8 @@ export class MessagingServicePlugin implements Plugin {
255261
private httpDispatcher?: HttpDispatcher;
256262
/** The engine the template placement hooks are bound to — unbound on teardown. */
257263
private placementEngine?: PlacementHookEngine;
264+
/** The engine the unset-digest hook is bound on (#35123; temporary until #36245). */
265+
private digestUnsetEngine?: PreferenceDigestHookEngine;
258266
/** The engine the Slack link removal triggers are bound to — unbound on teardown. */
259267
private slackTriggerEngine?: SlackTriggerEngine;
260268

@@ -471,6 +479,23 @@ export class MessagingServicePlugin implements Plugin {
471479
+ 'for where its body places a hole',
472480
);
473481
}
482+
// [ruling 7073270426 on #35123] An insert that leaves
483+
// `sys_notification_preference.digest` unset stores it EMPTY ("not
484+
// set") even where the column still carries the old physical DEFAULT
485+
// 'none', which would read as the person's explicit "no digest".
486+
// ⚠️ TEMPORARY, carried by #36245 (the SQL driver keeps a column
487+
// default the metadata no longer declares): removed when that lands.
488+
// See preference-digest-unset.ts.
489+
if (bindPreferenceDigestUnset(engine)) {
490+
this.digestUnsetEngine = engine;
491+
} else {
492+
ctx.logger.warn(
493+
'[messaging] no ObjectQL engine with a hook registry: on a database created by an earlier release, a '
494+
+ "notification preference created without a digest stores 'none', which reads as the person's own "
495+
+ "choice of no digest instead of following the organization's default",
496+
);
497+
}
498+
474499
// [ruling 7024100939, rider 3] A person's Slack links go when they
475500
// leave the organization or are banned (their deletion cascades by
476501
// the object's own declaration). See slack-links.ts.
@@ -540,6 +565,17 @@ export class MessagingServicePlugin implements Plugin {
540565
});
541566
}
542567

568+
// [ruling 7073270426 on #35123] `digest` lost its `defaultValue:
569+
// 'none'`: a stored `none` is now a person's explicit choice, and the
570+
// legacy `none` nobody chose becomes empty — ONCE per deployment,
571+
// recorded in `sys_migration`, never on every boot (that would erase
572+
// the choices made since). See preference-digest-conversion.ts.
573+
if (typeof ctx.hook === 'function') {
574+
ctx.hook('kernel:ready', async () => {
575+
await convertLegacyNoneDigestsOnce(getData(), ctx.logger);
576+
});
577+
}
578+
543579
// Email channel (ADR-0030 P3) + SMS channel (#2780): mounted through a
544580
// LAZY PROVIDER, so the mount TRACKS the transport service instead of
545581
// recording a verdict about it (#18050).
@@ -949,6 +985,8 @@ export class MessagingServicePlugin implements Plugin {
949985
async destroy(): Promise<void> {
950986
unbindTemplateHolePlacement(this.placementEngine);
951987
this.placementEngine = undefined;
988+
unbindPreferenceDigestUnset(this.digestUnsetEngine);
989+
this.digestUnsetEngine = undefined;
952990
unbindSlackLinkRemovalTriggers(this.slackTriggerEngine);
953991
this.slackTriggerEngine = undefined;
954992
await this.dispatcher?.stop();

‎packages/services/service-messaging/src/objects/notification-preference.object.ts‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,22 @@ export const NotificationPreference = ObjectSchema.create({
189189
description: 'When false, this (user, topic, channel) is muted.',
190190
}),
191191

192+
// [ruling 7073270426 on #35123] Three states, no `defaultValue`: empty
193+
// is "not set" and the next row decides (the organization's default,
194+
// then none); `none` is the explicit "send each one right away" and
195+
// decides. A default of `none` would store that choice on every row
196+
// nobody chose it for (`applyFieldDefaults` fills an omitted field on
197+
// insert). `preference-resolver.ts` `parseDigest` reads the states;
198+
// `preference-digest-unset.ts` keeps an omitted digest empty on a
199+
// database whose column still carries the old physical DEFAULT.
192200
digest: Field.select(['none', 'daily', 'weekly'], {
193201
label: 'Digest',
194202
required: false,
195-
defaultValue: 'none',
196203
description:
197204
'Collect these notifications into one summary instead of sending each as it arrives: daily sends it at midnight, ' +
198205
'weekly on Monday at midnight, none sends each one right away. Critical notifications are always sent at once. ' +
199-
'Takes effect on a preference whose channel is * (all channels).',
206+
'Takes effect on a preference whose channel is * (all channels). ' +
207+
'Left empty, the next preference decides: the default for all users, then none.',
200208
}),
201209

202210
quiet_hours: Field.json({
@@ -209,11 +217,15 @@ export const NotificationPreference = ObjectSchema.create({
209217
// unregistered widget degrades to the JSON editor.
210218
// `notification-preference-topic-channel-help.test.ts` pins it.
211219
widget: 'quiet-hours',
220+
// [ruling 7073270426 on #35123] Three states: empty is "not set"
221+
// (the next row decides), `{ "off": true }` is "no quiet hours, by
222+
// choice" (`QUIET_HOURS_OFF`) and decides, a window decides.
212223
description:
213224
'A daily window when notifications are held and delivered when it ends, for example ' +
214225
'{ "tz": "Europe/Berlin", "start": "22:00", "end": "07:00" }. Times are HH:MM in that time zone (UTC when tz is left out), ' +
215226
'and the window may run past midnight. Critical notifications are not held. ' +
216-
'Takes effect on a preference whose channel is * (all channels).',
227+
'Takes effect on a preference whose channel is * (all channels). ' +
228+
'{ "off": true } means no quiet hours; left empty, the next preference decides: the default for all users, then none.',
217229
}),
218230

219231
created_at: Field.datetime({ label: 'Created At', readonly: true }),

0 commit comments

Comments
 (0)