Skip to content

Commit 6f9f008

Browse files
feat(service-messaging): the notification preference quiet_hours declares the quiet-hours widget (#31534)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"} --> _Requested by **Leehom** · [project thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1X9QaksZP89FVq2pH6CVzsEb)_ Fixes #31426 Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:通知偏好的「免打扰」字段 `quiet_hours` 加上 `widget: 'quiet-hours'`,控制台改用时区加两个时间的控件,不再显示 JSON 编辑框;存储格式不变。 - 为什么改:#31421 的前端控件(PR #31459,已合并)只认字段上的 widget 提示,和同一对象的 topic、channel 一样,这是它的服务端一半。 - 风险与回滚:只是一个界面提示,不改字段类型、不新增拒绝;未注册该控件的宿主照旧显示 JSON 编辑框。回滚即还原本 PR。 - 先看:`packages/services/service-messaging/src/objects/notification-preference.object.ts` 的 `quiet_hours`。 - 两分钟验证:`cd packages/services/service-messaging && npx vitest run src/objects/notification-preference-topic-channel-help.test.ts`,预期 5 个全绿。 - 需要你做的:无,席位落地。 ## What changes - `sys_notification_preference.quiet_hours` declares `widget: 'quiet-hours'`, with a `[#30208 row 6, #31426]` comment like the ones on `topic` and `channel`. The field stays `json`; the stored shape `{ tz?, start: 'HH:MM', end: 'HH:MM' }` and every refusal are unchanged. The ui half registers `field:quiet-hours` (PR #31459, merged). - `content/docs/data-modeling/field-types.mdx` gains a short section on the three notification preference widgets (`notification-topic`, `notification-channel`, `quiet-hours`): which field each sits on, what it draws, what it stores, and that an unregistered name falls back to the type's default input. Per the ui seat's note on the card, the topic and channel hints were undocumented until now. - Changeset: `@objectstack/service-messaging` patch. ## Tests - `notification-preference-topic-channel-help.test.ts` (the file that pins the `topic` / `channel` hints) adds: `quiet_hours` declares `widget: 'quiet-hours'` and stays `json`. ## Verification <details><summary>Pin and ablation</summary> ``` npx vitest run src/objects/notification-preference-topic-channel-help.test.ts Tests 5 passed (5) scripts/ablation-replace.mjs --delete the widget line (landed; restored to the HEAD blob): × quiet_hours declares the quiet-hours widget and stays a json field (#31426) AssertionError: expected undefined to be 'quiet-hours' Tests 1 failed | 4 passed (5) ``` </details> <details><summary>Gates</summary> `node scripts/pm/dispatch-gates.mjs --commands` derives 94 families; all 94 run with each exit code captured before any pipe, all exit 0, and `--ran` reconciles: `94 derived famil(ies) accounted for — 94 run, 0 NOT-MEASURED`. After a typing fix in the new pin (a `required` read the field shape does not type), `pnpm --filter @objectstack/service-messaging typecheck` exits 0, `pnpm check:query-options-erasure` exits 0, the pin and its ablation were rerun as above, and `pnpm lint` over the two touched `.ts` files exits 0. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01FEkQ5kheduG7p1MXMoHHr4)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 827b193 commit 6f9f008

4 files changed

Lines changed: 36 additions & 0 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@objectstack/service-messaging': patch
3+
---
4+
5+
feat(service-messaging): the notification preference's `quiet_hours` declares the `quiet-hours` widget
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
`sys_notification_preference.quiet_hours` now carries `widget: 'quiet-hours'`, so the console draws its quiet-hours control (a time-zone picker and two times) instead of the JSON editor, as `topic` and `channel` already name their pick-or-type inputs. The field stays `json` with the same stored shape, `{ tz?, start: 'HH:MM', end: 'HH:MM' }`, and nothing new is refused. `field-types.mdx` documents the three notification preference widgets.

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,20 @@ has none, the list is empty, or the load fails, the field is a text box that
11391139
takes the typed name; a failure is shown with its cause, and the box stays
11401140
editable.
11411141
1142+
### Notification preference inputs (`notification-topic`, `notification-channel`, `quiet-hours`)
1143+
1144+
The platform's notification preference (`sys_notification_preference`) declares three
1145+
widgets, so the record form offers choices instead of a bare box:
1146+
1147+
| Widget | Field | Draws | Stores |
1148+
|---|---|---|---|
1149+
| `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 |
1150+
| `notification-channel` | `channel` (`text`) | the same list, marking a known channel whose service is not configured | the channel id as written, `*` for all |
1151+
| `quiet-hours` | `quiet_hours` (`json`) | a time-zone picker and two times | `{ tz?, start: 'HH:MM', end: 'HH:MM' }` |
1152+
1153+
A typed topic or channel the list does not hold is still stored. Like every `widget` value,
1154+
a name no host registers falls back to the type's default input.
1155+
11421156
### A widget's face on the record heading
11431157
11441158
A `text` field that declares `widget: 'recipient-picker'` or `widget: 'object-ref'` is drawn

‎packages/services/service-messaging/src/objects/notification-preference-topic-channel-help.test.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,9 @@ describe('sys_notification_preference topic / channel help (#25346)', () => {
9090
expect(templateFields.channel?.widget).toBeUndefined();
9191
expect(templateFields.channel?.type).toBe('text');
9292
});
93+
94+
it('quiet_hours declares the quiet-hours widget and stays a json field (#31426)', () => {
95+
expect(fields.quiet_hours?.widget).toBe('quiet-hours');
96+
expect(fields.quiet_hours?.type).toBe('json');
97+
});
9398
});

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,13 @@ export const NotificationPreference = ObjectSchema.create({
202202
quiet_hours: Field.json({
203203
label: 'Quiet Hours',
204204
required: false,
205+
// [#30208 row 6, #31426] The widget hint names the console's
206+
// quiet-hours control (#31421): a time-zone picker and two times
207+
// over the same stored `{ tz?, start: 'HH:MM', end: 'HH:MM' }`.
208+
// The field stays `json`, nothing new is refused, and an
209+
// unregistered widget degrades to the JSON editor.
210+
// `notification-preference-topic-channel-help.test.ts` pins it.
211+
widget: 'quiet-hours',
205212
description:
206213
'A daily window when notifications are held and delivered when it ends, for example ' +
207214
'{ "tz": "Europe/Berlin", "start": "22:00", "end": "07:00" }. Times are HH:MM in that time zone (UTC when tz is left out), ' +

0 commit comments

Comments
 (0)