Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .changeset/34728-notification-settings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
'@objectstack/service-messaging': patch
'@objectstack/plugin-security': patch
'@objectstack/platform-objects': patch
'@object-ui/app-shell': patch
'@object-ui/i18n': patch
---

feat(account): a Notification Settings page where each person chooses their own notification topics, channels, digest and quiet hours

Clause-②: yes
Metadata-protocol: none

The Account app has a new **Notification Settings** page, under Inbox and only when the messaging service runs. It shows one row per notification topic and one column per channel. Each cell shows whether that notification reaches you on that channel, and where the answer comes from: your own setting, your organization's default, the built-in default, or a mandatory topic. Mandatory topics are always delivered and cannot be switched off. A channel the deployment cannot send on yet says so in its column header. Above the matrix you can set your digest and your quiet hours.

- **The read: `GET /api/v1/messaging/me/preferences`.** This new door answers the signed-in person's *effective* preferences. The server computes them with the same resolver `emit` uses to filter (`PreferenceResolver.effectiveFor`), so the page shows what is actually sent and computes nothing itself. The door takes no parameters and answers only about the caller: there is no `user` parameter, and any parameter is refused `VALIDATION_ERROR` / `400`. It keeps the posture of `GET /api/v1/messaging/preference-options`:
- an anonymous caller gets `401`;
- a held sign-in gets `403`;
- a source it cannot read is `500` / `INTERNAL_ERROR`, never a partial or "everything on" answer.

The door reads only what the answer needs: the caller's own rows and the organization's default rows, each by equality on `user_id` within the caller's organization. A read that comes back with more rows than its cap is a fault (`500`), never a page.

The organization's defaults appear only as `source: 'default'` on the caller's own cells. No other person's row, and no row id except the caller's own, is ever answered.
- **The writes: your own `sys_notification_preference` rows, through the data door, as you.** `member_default`, the baseline set every signed-in person resolves (external members excepted), now carries a grant of read, create and edit on the object, with no delete. Two row policies come with it:
- `sys_notification_preference_self` binds every principal that holds the grant. Its row scope is `user_id == current_user.id`, and its write check is the same expression, so the row as written must still be your own.
- `sys_notification_preference_org_admin` widens organization owners and administrators back to every row of their organization. Its write check is `topic != null`, which holds on every row being created because `topic` is required with a default. If `topic` ever becomes optional, an administrator's create is refused, never widened.

An ordinary member or a delegated administrator lists only their own rows. Their create with `user_id` omitted, empty or naming another person is refused `403` / `PERMISSION_DENIED`, as is moving their own row to another person or to the organization default.
- **Owners and administrators are unchanged.** They still list every row, create and edit the organization default, create and edit another person's row, and delete in the Setup grid.
- **App-authored grants are narrowed too.** `sys_notification_preference_self` carries no `positions` domain, so it binds every principal that holds a grant on this object, including through an app's own permission set. A role other than organization owner or administrator that an app grants this object reads and writes only its own rows, unless the app declares its own widening policy for that role.

There is no "reset to the organization's default" button, because that needs a delete, which members are not granted. Changing your digest or quiet hours saves your own general setting, and the page says so beside the control. From then on, that setting applies in place of the organization's defaults to every topic and channel you have not set yourself.
9 changes: 6 additions & 3 deletions packages/cli/test/connect-agent-both-halves-wire.pin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,13 @@ describe('#17647 — Connect-an-Agent visibility: BOTH halves, over the wire', (
.toEqual(['nav_connect_agent']);
expect(groupChildren(account.body?.item, 'grp_account_developer'))
.toEqual(['nav_account_api_keys', 'nav_account_oauth_apps']);
// The whole served tree, counted: 13 authored ids (the AI Assistant
// The whole served tree, counted: 14 authored ids (the AI Assistant
// slot among them) + the one contributed. (12 authored until the
// Mobile App entry, `nav_account_mobile_app`, joined after Profile.)
expect(navIds(account.body?.item)).toHaveLength(14);
// Mobile App entry, `nav_account_mobile_app`, joined after Profile;
// 13 until the Notification Settings entry,
// `nav_account_notification_settings`, joined the Inbox group
// (#34728).)
expect(navIds(account.body?.item)).toHaveLength(15);
// …and the entry's TARGET rode along, so the menu item resolves.
expect(JSON.stringify(account.body)).toContain('connect_agent');

Expand Down
17 changes: 17 additions & 0 deletions packages/platform-objects/src/apps/account.app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,23 @@ export const ACCOUNT_APP: App = {
icon: 'bell',
requiresObject: 'sys_inbox_message',
},
{
// [rulings 6968686390 and 6969143776] The person's own notification
// settings: per topic × channel on/off, digest and quiet hours. A
// console page registered as `account:notification_settings`; it
// reads `GET /api/v1/messaging/me/preferences` (their EFFECTIVE
// preferences, computed by the resolver `emit` uses) and writes
// their own `sys_notification_preference` rows through the data
// door, where `member_default`'s own-row policy decides which rows.
// Gated like Approvals: the capability is the messaging SERVICE,
// which mounts the route the page reads.
id: 'nav_account_notification_settings',
type: 'component',
label: 'Notification Settings',
componentRef: 'account:notification_settings',
icon: 'bell-ring',
requiresService: 'messaging',
},
{
// #7234 — the DESTINATION is the Approvals Inbox component, not the
// raw `sys_approval_request` grid. The engine-owned table has no
Expand Down
1 change: 1 addition & 0 deletions packages/platform-objects/src/apps/translations/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const ar: TranslationData = {
nav_account_profile: { label: 'الملف الشخصي' },
nav_account_mobile_app: { label: 'تطبيق الجوال' },
nav_account_notifications: { label: 'الإشعارات' },
nav_account_notification_settings: { label: 'إعدادات الإشعارات' },
nav_account_approvals: { label: 'بانتظار موافقتي' },
nav_account_memberships: { label: 'مؤسساتي' },
nav_account_linked: { label: 'الحسابات المرتبطة' },
Expand Down
1 change: 1 addition & 0 deletions packages/platform-objects/src/apps/translations/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const de: TranslationData = {
nav_account_profile: { label: 'Profil' },
nav_account_mobile_app: { label: 'Mobile-App' },
nav_account_notifications: { label: 'Benachrichtigungen' },
nav_account_notification_settings: { label: 'Benachrichtigungseinstellungen' },
nav_account_approvals: { label: 'Meine ausstehenden Genehmigungen' },
nav_account_memberships: { label: 'Meine Organisationen' },
nav_account_linked: { label: 'Verknüpfte Konten' },
Expand Down
1 change: 1 addition & 0 deletions packages/platform-objects/src/apps/translations/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const en: TranslationData = {
nav_account_profile: { label: 'Profile' },
nav_account_mobile_app: { label: 'Mobile App' },
nav_account_notifications: { label: 'Notifications' },
nav_account_notification_settings: { label: 'Notification Settings' },
nav_account_approvals: { label: 'Approvals' },
nav_account_memberships: { label: 'My Organizations' },
nav_account_linked: { label: 'Linked Accounts' },
Expand Down
1 change: 1 addition & 0 deletions packages/platform-objects/src/apps/translations/es-ES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const esES: TranslationData = {
nav_account_profile: { label: 'Perfil' },
nav_account_mobile_app: { label: 'Aplicación móvil' },
nav_account_notifications: { label: 'Notificaciones' },
nav_account_notification_settings: { label: 'Configuración de notificaciones' },
nav_account_approvals: { label: 'Aprobaciones pendientes' },
nav_account_memberships: { label: 'Mis organizaciones' },
nav_account_linked: { label: 'Cuentas vinculadas' },
Expand Down
1 change: 1 addition & 0 deletions packages/platform-objects/src/apps/translations/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const fr: TranslationData = {
nav_account_profile: { label: 'Profil' },
nav_account_mobile_app: { label: 'Application mobile' },
nav_account_notifications: { label: 'Notifications' },
nav_account_notification_settings: { label: 'Paramètres de notification' },
nav_account_approvals: { label: 'Mes approbations en attente' },
nav_account_memberships: { label: 'Mes organisations' },
nav_account_linked: { label: 'Comptes liés' },
Expand Down
1 change: 1 addition & 0 deletions packages/platform-objects/src/apps/translations/ja-JP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const jaJP: TranslationData = {
nav_account_profile: { label: 'プロフィール' },
nav_account_mobile_app: { label: 'モバイルアプリ' },
nav_account_notifications: { label: '通知' },
nav_account_notification_settings: { label: '通知設定' },
nav_account_approvals: { label: '承認待ち' },
nav_account_memberships: { label: '所属組織' },
nav_account_linked: { label: '連携アカウント' },
Expand Down
1 change: 1 addition & 0 deletions packages/platform-objects/src/apps/translations/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const ko: TranslationData = {
nav_account_profile: { label: '프로필' },
nav_account_mobile_app: { label: '모바일 앱' },
nav_account_notifications: { label: '알림' },
nav_account_notification_settings: { label: '알림 설정' },
nav_account_approvals: { label: '내 승인 대기' },
nav_account_memberships: { label: '내 조직' },
nav_account_linked: { label: '연결된 계정' },
Expand Down
1 change: 1 addition & 0 deletions packages/platform-objects/src/apps/translations/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const ptBR: TranslationData = {
nav_account_profile: { label: 'Perfil' },
nav_account_mobile_app: { label: 'Aplicativo móvel' },
nav_account_notifications: { label: 'Notificações' },
nav_account_notification_settings: { label: 'Configurações de notificação' },
nav_account_approvals: { label: 'Minhas aprovações pendentes' },
nav_account_memberships: { label: 'Minhas organizações' },
nav_account_linked: { label: 'Contas vinculadas' },
Expand Down
1 change: 1 addition & 0 deletions packages/platform-objects/src/apps/translations/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const ru: TranslationData = {
nav_account_profile: { label: 'Профиль' },
nav_account_mobile_app: { label: 'Мобильное приложение' },
nav_account_notifications: { label: 'Уведомления' },
nav_account_notification_settings: { label: 'Настройки уведомлений' },
nav_account_approvals: { label: 'Ждут моего решения' },
nav_account_memberships: { label: 'Мои организации' },
nav_account_linked: { label: 'Связанные учётные записи' },
Expand Down
1 change: 1 addition & 0 deletions packages/platform-objects/src/apps/translations/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const zhCN: TranslationData = {
nav_account_profile: { label: '个人资料' },
nav_account_mobile_app: { label: '移动应用' },
nav_account_notifications: { label: '通知' },
nav_account_notification_settings: { label: '通知设置' },
nav_account_approvals: { label: '待我审批' },
nav_account_memberships: { label: '我的组织' },
nav_account_linked: { label: '已关联账户' },
Expand Down
1 change: 1 addition & 0 deletions packages/platform-objects/src/apps/translations/zh-Hant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const zhHant: TranslationData = {
nav_account_profile: { label: '個人資料' },
nav_account_mobile_app: { label: '移動應用' },
nav_account_notifications: { label: '通知' },
nav_account_notification_settings: { label: '通知設定' },
nav_account_approvals: { label: '待我核准' },
nav_account_memberships: { label: '我的組織' },
nav_account_linked: { label: '已關聯帳戶' },
Expand Down
1 change: 1 addition & 0 deletions packages/plugins/plugin-security/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"@objectstack/plugin-audit": "workspace:*",
"@objectstack/plugin-sharing": "workspace:*",
"@objectstack/service-i18n": "workspace:*",
"@objectstack/service-messaging": "workspace:*",
"@types/node": "^26.6.5",
"tsx": "^4.23.15",
"typescript": "^6.0.3",
Expand Down
Loading
Loading