Notification bell (and avatars) only exist when peering state is configured; make the bell feature-independent with per-source gating #836

Closed
opened 2026-10-03 15:55:41 +00:00 by Cordy · 2 comments
Owner

Found in the #833 final review; scope decided by Nikola on 2026-10-03.

Peering is a secure send, not sharing. Public links and internal shares exist whether or not peering or OCM is enabled, so their notifications must not depend on either. The bell should be built per source: each kind of item appears when its own feature is active.

Code investigation (main @ v0.6.316)

  • cmd/cairnd/main.go ~1452-1604: everything inside if cfg.Peering.StatePath != "" { … } is built only when a peering state path is configured. That includes:
    • seenStore (notify-seen.json) and apiH.Notify = &api.NotifyAPI{…}. Without it registerNotify is never called (internal/api/api.go:222), so /api/v1/notifications and the notification prefs routes return 404. pollBell then hides the bell button (web/static/index.html ~17509).
    • apiH.Avatars (~1587). Profile pictures also disappear on an instance without a peering state path. This is an unrelated feature caught in the same block.
    • apiH.Notify.SpaceAlerts is wired later (~1662) with an if apiH.Notify != nil guard, so it is silently dropped too.
  • The default config sets peering.statePath (/data/.cairn/peering.json), so the dogfoods are fine. An operator who blanks it to switch peering off loses everything the bell carries:
    • received/sent transfers (correctly)
    • OCM invitations (wrongly)
    • lapsed locks
    • licence drop/restore
    • audit failing
    • Space full/warn
    • the #833 admin-revoke, review-due and report items
    • avatars
  • The opposite problem also exists. With peering constructed but switched off at runtime (peeringEnabled=false), and OCM switched off (OCMEnabled=false), the feed still shows their items:
    • Inbox "received" items and "sent" transfers are derived from /home/<u>/Inbox and the transfers store, whatever the switch.
    • Pending OCM invitations are derived from the OCM ledger even when OCM is off, although the user can no longer accept them.
  • The notification prefs list every kind (notifPrefKinds, internal/api/notify.go ~290-345), including those of disabled features.
  • The empty-state text still reads "Files sent to or received from a peered instance appear here." (notifEmptyHint, 4 languages). That is outdated now that the bell carries locks, licence, storage, audit and sharing items.
  • What is already right. The design is derived: nothing is stored per notification, and each item disappears with the state it described. This is the main reason Cairn avoids the table bloat Nextcloud admins report with oc_notifications, where installs reach millions of rows and gigabytes. Keep this design.

What others do

  • Nextcloud.
    • Notifications are a separate app. Sharing, activity, Talk and others register their own notifiers, so each source stays independent of the others.
    • Users can choose to auto-accept incoming shares or confirm each one.
    • Admins report oc_notifications and oc_activity growing to millions of rows and needing cleanup. Cairn's derived bell avoids this.
  • ownCloud Infinite Scale.
    • A notifications service subscribes to the event bus.
    • Share and unshare notifications exist since 7.2, along with Space membership notifications.
    • Users choose in-app and/or email delivery, with daily or weekly email digests sent by a cron job. Each source is gated independently.
  • Google Drive.
    • Files shared with someone are a spam vector. Unsolicited shares and their notifications were abused enough that Google added a Drive spam folder and block user (2023).
    • Blocking a user removes what they shared and unsubscribes their notifications.

Security and privacy concerns

  1. Cross-user leakage. Each source must filter strictly per recipient. Admin-only kinds stay admin-only, as today for licence, audit, Space and review items.
  2. Feature-off means silent. A disabled feature must not surface actions the user can no longer take, such as pending OCM invites with OCM off.
  3. Abuse and spam. If incoming-share notifications are added (Phase 2), anyone who can share can push items into another user's bell. Plan for it: per-kind mute (exists), and later per-sender mute or block (Google precedent). Group shares to large groups need care.
  4. Poll cost. The feed walks Inbox and transfers per user, with a 45 s cache per user. New sources must stay cheap or cached, and must never list the whole share store per poll (#833 lesson).
  5. Privacy and retention. Derived items obey the notification horizon (settings NotifyRetention). Nothing extra is persisted.

Plan

Phase 1: decouple (v0.7, no behaviour change for default deployments)

  1. Unconditional construction. Build seenStore, NotifyAPI and AvatarsAPI outside the peering block in main.go. Inside the block, only attach peering's sources: Transfers and the Inbox walker.
  2. Runtime gates per source in derive.
    • received/sent only when peering is constructed and peeringEnabled;
    • ocm-share only when OCMEnabled;
    • locks, licence, audit, Space and share-review/activity always, with their existing admin rules.
    • Decision for Nikola: when a feature is switched off, its historical items are hidden (proposed). Files already in the Inbox are untouched.
  3. Prefs reflect the active sources. GET /notifications/prefs returns only kinds whose source is active, and the UI hides the other toggles. Stored mutes for inactive kinds are kept, not deleted.
  4. Generic empty-state text in 4 languages, no long dash, e.g. "Notifications about your files, shares and this server appear here."
  5. Tests:
    • with Peering.StatePath == "": /notifications and /notifications/prefs return 200, an admin-revoke owner item appears, and /avatars works;
    • with peeringEnabled=false: no received/sent items;
    • with OCMEnabled=false: no ocm-share items;
    • prefs list kinds per active source;
    • a main.go wiring guard, using the seam #833 lacked. A small buildNotify(...) function would make it testable.
  6. Docs: handbook notifications section (what appears when) and a CHANGELOG entry.

Phase 2: proposal for Nikola's decision, not part of Phase 1

  • "Shared with you" for internal shares. Cairn has no notification when someone shares a file or folder with you; Nextcloud, oCIS and Google all have one.
    • Proposed kind: share-received, user and group grants, derived from grants where the user is the addressee or a group member, within the horizon.
    • Mute key: share-activity, which exists since #833.
    • Questions:
      • do group grants notify every member, or only small groups?
      • do we need per-sender mute before shipping (spam vector)?
  • "Link expires soon" for link owners, derived from ExpiresAt (for example 3 days before). This is cheap and useful; others commonly send this by email.
  • Email delivery or digests (oCIS model) stay out of scope until Cairn has SMTP.

Refs:

Found in the #833 final review; scope decided by Nikola on 2026-10-03. Peering is a **secure send**, not sharing. Public links and internal shares exist whether or not peering or OCM is enabled, so their notifications must not depend on either. The bell should be built per source: each kind of item appears when **its own** feature is active. ## Code investigation (main @ v0.6.316) - `cmd/cairnd/main.go` ~1452-1604: everything inside `if cfg.Peering.StatePath != "" { … }` is built **only** when a peering state path is configured. That includes: - `seenStore` (`notify-seen.json`) and `apiH.Notify = &api.NotifyAPI{…}`. Without it `registerNotify` is never called (`internal/api/api.go:222`), so `/api/v1/notifications` and the notification prefs routes return 404. `pollBell` then hides the bell button (`web/static/index.html` ~17509). - `apiH.Avatars` (~1587). **Profile pictures also disappear** on an instance without a peering state path. This is an unrelated feature caught in the same block. - `apiH.Notify.SpaceAlerts` is wired later (~1662) with an `if apiH.Notify != nil` guard, so it is silently dropped too. - **The default config sets `peering.statePath`** (`/data/.cairn/peering.json`), so the dogfoods are fine. An operator who blanks it to switch peering off loses everything the bell carries: - received/sent transfers (correctly) - OCM invitations (wrongly) - lapsed locks - licence drop/restore - audit failing - Space full/warn - the #833 admin-revoke, review-due and report items - avatars - **The opposite problem also exists.** With peering constructed but switched off at runtime (`peeringEnabled=false`), and OCM switched off (`OCMEnabled=false`), the feed still shows their items: - Inbox "received" items and "sent" transfers are derived from `/home/<u>/Inbox` and the transfers store, whatever the switch. - Pending OCM invitations are derived from the OCM ledger even when OCM is off, although the user can no longer accept them. - **The notification prefs** list every kind (`notifPrefKinds`, `internal/api/notify.go` ~290-345), including those of disabled features. - **The empty-state text** still reads "Files sent to or received from a peered instance appear here." (`notifEmptyHint`, 4 languages). That is outdated now that the bell carries locks, licence, storage, audit and sharing items. - **What is already right.** The design is derived: nothing is stored per notification, and each item disappears with the state it described. This is the main reason Cairn avoids the table bloat Nextcloud admins report with `oc_notifications`, where installs reach millions of rows and gigabytes. Keep this design. ## What others do - **Nextcloud.** - Notifications are a separate app. Sharing, activity, Talk and others register their own notifiers, so each source stays independent of the others. - Users can choose to auto-accept incoming shares or confirm each one. - Admins report `oc_notifications` and `oc_activity` growing to millions of rows and needing cleanup. Cairn's derived bell avoids this. - **ownCloud Infinite Scale.** - A notifications **service** subscribes to the event bus. - Share and unshare notifications exist since 7.2, along with Space membership notifications. - Users choose in-app and/or email delivery, with daily or weekly email digests sent by a cron job. Each source is gated independently. - **Google Drive.** - Files shared with someone are a spam vector. Unsolicited shares and their notifications were abused enough that Google added a Drive **spam folder** and **block user** (2023). - Blocking a user removes what they shared and unsubscribes their notifications. ## Security and privacy concerns 1. **Cross-user leakage.** Each source must filter strictly per recipient. Admin-only kinds stay admin-only, as today for licence, audit, Space and review items. 2. **Feature-off means silent.** A disabled feature must not surface actions the user can no longer take, such as pending OCM invites with OCM off. 3. **Abuse and spam.** If incoming-share notifications are added (Phase 2), anyone who can share can push items into another user's bell. Plan for it: per-kind mute (exists), and later per-sender mute or block (Google precedent). Group shares to large groups need care. 4. **Poll cost.** The feed walks Inbox and transfers per user, with a 45 s cache per user. New sources must stay cheap or cached, and must never list the whole share store per poll (#833 lesson). 5. **Privacy and retention.** Derived items obey the notification horizon (settings `NotifyRetention`). Nothing extra is persisted. ## Plan ### Phase 1: decouple (v0.7, no behaviour change for default deployments) 1. **Unconditional construction.** Build `seenStore`, `NotifyAPI` and `AvatarsAPI` **outside** the peering block in `main.go`. Inside the block, only attach peering's sources: `Transfers` and the Inbox walker. 2. **Runtime gates per source in `derive`.** - received/sent only when peering is constructed **and** `peeringEnabled`; - `ocm-share` only when `OCMEnabled`; - locks, licence, audit, Space and share-review/activity always, with their existing admin rules. - **Decision for Nikola:** when a feature is switched off, its historical items are hidden (proposed). Files already in the Inbox are untouched. 3. **Prefs reflect the active sources.** `GET /notifications/prefs` returns only kinds whose source is active, and the UI hides the other toggles. Stored mutes for inactive kinds are kept, not deleted. 4. **Generic empty-state text** in 4 languages, no long dash, e.g. "Notifications about your files, shares and this server appear here." 5. **Tests:** - with `Peering.StatePath == ""`: `/notifications` and `/notifications/prefs` return 200, an admin-revoke owner item appears, and `/avatars` works; - with `peeringEnabled=false`: no received/sent items; - with `OCMEnabled=false`: no `ocm-share` items; - prefs list kinds per active source; - a `main.go` wiring guard, using the seam #833 lacked. A small `buildNotify(...)` function would make it testable. 6. **Docs:** handbook notifications section (what appears when) and a CHANGELOG entry. ### Phase 2: proposal for Nikola's decision, not part of Phase 1 - **"Shared with you" for internal shares.** Cairn has no notification when someone shares a file or folder with you; Nextcloud, oCIS and Google all have one. - Proposed kind: `share-received`, user and group grants, derived from grants where the user is the addressee or a group member, within the horizon. - Mute key: `share-activity`, which exists since #833. - Questions: - do group grants notify every member, or only small groups? - do we need per-sender mute before shipping (spam vector)? - **"Link expires soon"** for link owners, derived from `ExpiresAt` (for example 3 days before). This is cheap and useful; others commonly send this by email. - **Email delivery or digests** (oCIS model) stay out of scope until Cairn has SMTP. Refs: - https://github.com/nextcloud/notifications/blob/master/docs/notification-workflow.md - https://docs.nextcloud.com/server/stable/user_manual/en/files/sharing.html - https://help.nextcloud.com/t/oc-activity-und-oc-notifications-in-der-db-sehr-gross/187845 - https://doc.owncloud.com/ocis/next/deployment/services/s-list/notifications.html - https://doc.owncloud.com/ocis_release_notes.html - https://workspaceupdates.googleblog.com/2023/05/google-drive-spam-folder.html
Author
Owner

Research (2026-10-08): notifications of a feature that was switched off

  • Gitea, three CVEs in 2026. After repository access was revoked, notifications kept exposing private data:

    • the notification API kept showing private issue and PR titles, URLs, state and new comments to users who had lost access (CVE-2026-58419);
    • release notification emails kept going out after a repo turned private (CVE-2026-0798);
    • the details endpoint didn't re-check access (CVE-2026-20800).

    The first fix gated only the repository object, so the problem returned. Lesson: notifications must be re-checked against current state every time they are shown. Cairn's derived bell already does this, and per-source gating extends it to "feature switched off".

  • Nextcloud: stored notifications of a disabled or removed app stay in the queue with no notifier. They show up as log noise ("Notification was not parsed by any notifier") until someone cleans them up (forum, server#62478). This is the stored-notifications failure mode the derived design avoids.

  • Design guidance:

    • GNOME HIG: an app must remove notifications that are no longer valid, for example a revoked weather warning (GNOME).
    • Apple HIG: people dislike informative but non-actionable interruptions, and the same thing shouldn't be notified repeatedly (Apple HIG).
    • Users ask for auto-clearing when the underlying event is gone (Cursor forum).
  • ISO: no specific control. A.8.15 and A.8.3 (information access restriction) argue against surfacing data a user can no longer act on or access.

Recommendation stays "hide". While a feature is off its items aren't shown. Because the bell is derived, they come back unchanged when the feature is switched on again. Nothing is deleted, and files already received stay where they are.

## Research (2026-10-08): notifications of a feature that was switched off - **Gitea, three CVEs in 2026.** After repository access was revoked, notifications kept exposing private data: - the notification API kept showing private issue and PR titles, URLs, state and new comments to users who had lost access ([CVE-2026-58419](https://securelayer7.net/lab/cve-2026-58419-gitea-notification-api-private-metadata-leak)); - release notification emails kept going out after a repo turned private ([CVE-2026-0798](https://advisories.gitlab.com/golang/code.gitea.io/gitea/CVE-2026-0798/)); - the details endpoint didn't re-check access ([CVE-2026-20800](https://vuln.today/cve/CVE-2026-20800)). The first fix gated only the repository object, so the problem returned. **Lesson:** notifications must be re-checked against current state every time they are shown. Cairn's derived bell already does this, and per-source gating extends it to "feature switched off". - **Nextcloud:** stored notifications of a disabled or removed app stay in the queue with no notifier. They show up as log noise ("Notification was not parsed by any notifier") until someone cleans them up ([forum](https://help.nextcloud.com/t/warnings-for-a-not-installed-app/246185), [server#62478](https://github.com/nextcloud/server/issues/62478)). This is the stored-notifications failure mode the derived design avoids. - **Design guidance:** - GNOME HIG: an app must **remove notifications that are no longer valid**, for example a revoked weather warning ([GNOME](https://developer.gnome.org/hig/patterns/feedback/notifications.html)). - Apple HIG: people dislike **informative but non-actionable** interruptions, and the same thing shouldn't be notified repeatedly ([Apple HIG](https://developer-rno.apple.com/design/human-interface-guidelines/components/system-experiences/notifications)). - Users ask for auto-clearing when the underlying event is gone ([Cursor forum](https://forum.cursor.com/t/remove-stale-system-notifications/168721)). - **ISO:** no specific control. A.8.15 and A.8.3 (information access restriction) argue against surfacing data a user can no longer act on or access. **Recommendation stays "hide".** While a feature is off its items aren't shown. Because the bell is derived, they come back unchanged when the feature is switched on again. Nothing is deleted, and files already received stay where they are.
Author
Owner

Decision (Nikola, 2026-10-08): hide while the feature is off. A switched-off feature's items aren't shown, and they reappear unchanged when it's switched back on. Nothing is deleted, and files already received stay. Phase 1 as planned. Phase 2 ("shared with you", "link expires soon") stays a separate decision later.

**Decision (Nikola, 2026-10-08): hide while the feature is off.** A switched-off feature's items aren't shown, and they reappear unchanged when it's switched back on. Nothing is deleted, and files already received stay. Phase 1 as planned. Phase 2 ("shared with you", "link expires soon") stays a separate decision later.
Cordy closed this issue 2026-10-08 18:06:18 +00:00
Sign in to join this conversation.
No labels
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Cordy/Cairn#836
No description provided.