Skip to content

fix(notifications): require household authority for Discord changes - #2756

Merged
Quick104 merged 5 commits into
mainfrom
fix/discord-destination-household-authority
Oct 20, 2026
Merged

Quick104 merged 5 commits into
mainfrom
fix/discord-destination-household-authority

Conversation

@Quick104

@Quick104 Quick104 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Closes #2752
Related issue: N/A
Validation tasks: changes #1234 C1; changes #1235 C1-C2

A secondary household profile could change the account-wide Discord destination or delivery mode. This applies the existing household-manager and PIN rules to link initiation, unlinking and mode changes on both native API versions.

Approach

Both versions use the existing household authorization through a shared handler dependency. Account admin status does not grant a secondary profile household authority. Documented profile-less exceptions remain, and reads and account-wide delivery keep their existing behavior.

The web settings page disables these controls for secondary or unresolved profiles and explains how to switch to the primary profile. The API contract documentation records the restriction and the critical v1 bridge fix.

Validation

  • Live check on a disposable sandbox, same database for both builds. On the merge base, a secondary profile (on a member account and on the admin account) and a member session with no profile could change the Discord mode, unlink, and start a new link on both /api/v1 and /api/v2. On the PR head those requests return v1 403 forbidden or v2 403 permission_denied; primary profiles still succeed, a PIN-locked primary succeeds only with a verified X-Profile-Token, and a profile-less admin session succeeds until a profile on the household has a limit. Reads are unchanged. No OAuth exchange or message delivery was performed; the Discord credentials were placeholders.
  • Go: the internal/api/handlers and internal/apiv2 packages pass in full, plus the internal/api package; make verify-apiv2-openapi verify-apiv2-web-types verify-apiv2-fixtures verify-route-inventory is current and make lint-changed reports no issues.
  • Web: the settings page tests (23 files, 240 tests) and tsc -b pass.
  • The earlier ci / Go test failure was TestAdminDefaultChangeReachesEveryViewer, which failed on main too and is fixed by fix(events): deliver administrator default changes to every viewer #2754; main is merged into this branch.
  • Notification tasks Notifications — Server #1234 and Notifications — Web #1235 have no recorded passes, so no validated result changes. The board-wide passed-case query was unavailable because project-read permission is missing.

Evidence

Before-and-after captures of the Discord settings group for a secondary profile (linked and unlinked, desktop and phone) and for the primary profile, plus the API responses for every caller above on both builds.

Evidence: https://evidence.siloserver.org/r/silo-server/issue-2752/

Risks

Secondary profiles now receive the existing permission errors when attempting these account-wide writes; locked primary profiles require verification. Existing OAuth state lifetime and callback revocation behavior are outside this change.

Apple and Android source contain no callers for these Discord management endpoints, and jellycompat exposes no equivalent surface. User manual: Silo-Server/siloserver.org#265, draft docs PR Silo-Server/siloserver.org#266. The draft waits for this code PR; its local captures are retained while evidence publication for the dotted repository name is blocked.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • The Evidence section shows every change a user can see.

AI Disclosure

  • Harness: Codex in T3 Code; Claude Code through T3 Code for independent approach and adversarial review.
  • Tool(s): Codex, T3 Code delegated review and collaborative browser tools, Modern Go Guidelines CLI, and the Silo evidence CLI.
  • Model(s): gpt-6.1-sol (implementation and independent source reviews); claude-opus-5-5 (approach review, adversarial reviews, and the two review fixes).
  • Involvement: AI-assisted; agents implemented and reviewed the change. Human review is pending.
  • Adversarial review: The Claude approach review led to shared dependency construction, compatible errors and selected-primary web controls. A claude-opus-5-5 background review at a8650cb89 found no verified defects. A later claude-opus-5-5 review in Claude Code, with a gpt-6.1-sol (Codex) adversarial round that found nothing, reported two low-severity findings; it fixed both on this branch (the shared household admission helper and the OpenAPI descriptions) and ran the sandbox check above.

Note

Require household-manager authority for Discord notification mutations

  • Adds a household-manager authorization gate to Discord link initiation, unlinking, and mode changes in both v1 and v2 APIs. Unauthorized or unverified callers now get 403 (v1) or a typed permission-denied problem (v2) before any backend call.
  • Adds the shared helper mayManageHouseholdOf in household.go, which resolves the user's store from an account ID and fails closed on missing wiring. The v2 guard requireDiscordNotificationManagement in notification_channels.go applies the same rule at the registry level, with NotificationDiscordManagement as an optional dependency on apiv2.Dependencies.
  • The Discord settings UI in NotificationsSettings.tsx now shows mutation controls only for the primary profile and disables them otherwise.
  • Documents the new read-vs-mutation authorization split across the API contract and notification docs, and adds authority matrix and fail-closed tests for both API versions.
  • Behavioral Change: v1 PUT /api/v1/notifications/discord-preferences, DELETE /api/v1/notifications/discord-link, and POST /api/v1/notifications/discord/link/init, plus their v2 equivalents, previously allowed any authenticated caller and now require household-manager (primary profile with PIN) authority; missing management wiring returns an error instead of proceeding.

Macroscope summarized 0d1b767.

@silo-triage silo-triage Bot added the size/XL 500–999 added + deleted lines (all files); change volume, not priority. label Oct 20, 2026
@silo-kody

silo-kody Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@macroscopeapp

macroscopeapp Bot commented Oct 20, 2026

Copy link
Copy Markdown

Evidence covers the web settings change, but not the API authorization change. The v1 and v2 handlers now reject secondary-profile writes; the linked page is described as UI captures only. Please add before-and-after response excerpts for the same secondary-profile request showing the prior success and the new 403 behavior.

Suggested fix: No diff; add the matching API response excerpts under Evidence.

Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness.

Posted via Macroscope — Visible change evidence

@silo-triage silo-triage Bot added bug Something isn't working go Pull requests that update go code impact: security Auth, privacy, or permission boundary priority: P0 Fix/merge first: data-loss, security, or widespread breakage labels Oct 20, 2026
@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 96d23af8-e0e3-422d-8c54-84834b3592f6
📥 Commits

Reviewing files that changed from the base of the PR and between ed40fa2 and a8650cb.

📒 Files selected for processing: 18
  • contracts/api/v2/fixtures/index.json
  • docs/architecture/api-contract.md
  • docs/architecture/v1-scope.md
  • docs/notifications-api.md
  • internal/api/handlers/notifications_discord.go
  • internal/api/handlers/notifications_discord_authority_test.go
  • internal/api/router.go
  • internal/api/router_discord_authority_test.go
  • internal/apiv2/fixtures_test.go
  • internal/apiv2/notification_channels.go
  • internal/apiv2/notification_channels_test.go
  • internal/apiv2/notification_discord_admission_test.go
  • internal/apiv2/notification_discord_household_test.go
  • internal/apiv2/notification_discord_links.go
  • internal/apiv2/notification_discord_links_test.go
  • internal/apiv2/router.go
  • web/src/pages/settings/NotificationsSettings.discord.test.tsx
  • web/src/pages/settings/NotificationsSettings.tsx

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.

📝 Walkthrough

Discord link initiation, unlinking, and preference changes now require household-manager authority across the v1 and v2 APIs. API wiring supplies profile-verification dependencies, the settings page limits management controls to the primary profile, and tests and fixtures cover authorization outcomes.

Changes: Discord notification management

Layer / File(s) Summary
v1 authorization and handler wiring
docs/architecture/*, docs/notifications-api.md, internal/api/handlers/notifications_discord*, internal/api/router.go, internal/api/router_discord_authority_test.go
The v1 handler checks household-manager authority before preference updates, unlinking, and link initiation. Router construction supplies user-store and profile-token dependencies. Documentation and tests cover the authorization rules and failure responses.
v2 authorization and mutation checks
contracts/api/v2/fixtures/index.json, internal/apiv2/fixtures_test.go, internal/apiv2/notification_channels*, internal/apiv2/notification_discord_*, internal/apiv2/router.go
The v2 registry checks Discord management authority before link initiation, unlinking, and delivery-mode changes. Fixtures and tests cover authorized, rejected, and fail-closed requests.
Primary-profile settings controls
web/src/pages/settings/NotificationsSettings.tsx, web/src/pages/settings/NotificationsSettings.discord.test.tsx
The settings page disables Discord management controls for non-primary profiles and displays a notice. Tests cover control availability and mutations for primary and secondary profiles.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant APIClient
  participant DiscordLinkInitHandler
  participant Registry
  participant NotificationDiscordManagementService
  participant DiscordLinkService
  APIClient->>DiscordLinkInitHandler: Request link initialization
  DiscordLinkInitHandler->>Registry: Check Discord management authority
  Registry->>NotificationDiscordManagementService: Verify user and profile authority
  NotificationDiscordManagementService-->>Registry: Authorization result
  Registry-->>DiscordLinkInitHandler: Allow or return an authorization problem
  DiscordLinkInitHandler->>DiscordLinkService: Start link flow when authorized
Loading

Suggested reviewers: rhainland

Merge Risk: ⚪ Minimal · up to a8650

Discord link, unlink and delivery-mode changes now require household-manager authority, and the settings page limits those controls to the primary profile. I found no concrete merge-blocking risk. Live provider integration was not validated, which is normal for this kind of change.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 26.32% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 14 files. (4 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: requiring household authority for Discord notification mutations.
Linked Issues check Passed Issue #2752 requires household-manager and PIN authorization for Discord link initiation, unlinking, and delivery-mode changes. The reviewed changes add shared household authorization to native API v1…
Out of Scope Changes check Passed The changed documentation records the new authorization contract and v1 behavior. Fixture updates, router wiring, and automated tests support the Discord authorization change. Web changes implement th…
Description check Passed The pull request description directly explains the Discord notification authorization changes, affected API versions and web controls, documentation updates, validation, risks, and scope. It matches t…
Full details: Linked Issues check

Explanation

Issue #2752 requires household-manager and PIN authorization for Discord link initiation, unlinking, and delivery-mode changes. The reviewed changes add shared household authorization to native API v1 and v2, wire the required dependencies, and add fail-closed coverage. The tests cover primary, secondary, restricted, locked, profile-less, and admin cases. The web settings disable these mutations for non-primary or unresolved profiles. The summaries state that profile-less exceptions, account-wide delivery, reads, and callback behavior remain unchanged.

Full details: Out of Scope Changes check

Explanation

The changed documentation records the new authorization contract and v1 behavior. Fixture updates, router wiring, and automated tests support the Discord authorization change. Web changes implement the issue requirement for web settings. No unrelated change is demonstrated in the reviewed change summary. Native app and Jellyfin parity, provider integration, and live deployment work are explicitly outside the issue scope.

Full details: Description check

Explanation

The pull request description directly explains the Discord notification authorization changes, affected API versions and web controls, documentation updates, validation, risks, and scope. It matches the changeset.

Full details: Docstring Coverage

Explanation

Docstring coverage is 26.32% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 14 files. (4 skipped: 4 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 2
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@macroscopeapp

macroscopeapp Bot commented Oct 20, 2026

Copy link
Copy Markdown

#1235 C1-C2 overstates the impact: those cases cover event-type preferences/web push and web inbox receipt/open/opt-out. The diff adds household-manager admission to Discord link/mode mutations; the event-preference and inbox-delivery paths are unchanged. Keep #1234 C1, which covers all channels and Discord opt-out. Please narrow the line to:

Validation tasks: changes #1234 C1

All relevant task results are Not run, so there is no recorded result to invalidate or unblock.

Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed.

Posted via Macroscope — v1 validation impact

@Quick104 Quick104 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of a8650cb89. The approach is right: Discord delivery covers every profile on the account, so changing where it goes belongs to the household manager, and this reuses the existing primary-profile and PIN rule on both API versions instead of adding a new one. I reproduced the defect on a sandbox built from the base commit (a secondary profile could change the mode, unlink, and start a new link on both /api/v1 and /api/v2) and will check the fixed build the same way.

Two low-severity findings, both inline. I'm fixing both in commits on this branch, so there's no need to change anything yourself.

A Codex (gpt-6.1-sol) adversarial round found no defects.

Comment thread internal/apiv2/notification_channels.go Resolved
@silo-kody

silo-kody Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@Quick104

Quick104 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor Author

Review summary

Reviewed head: 0d1b7677f (the author's a8650cb89, two review fixes, and current main merged in).

The fix holds up. Discord delivery covers every profile on an account, so re-linking, unlinking, or changing its mode is household management, and this PR applies the existing household-manager rule (canManageHouseholdAs) to those writes on both API versions instead of inventing a new one. The admin role is handled correctly: a secondary profile on an admin account is refused like any other secondary profile, and only the documented profile-less admin exceptions remain.

Findings

Both were low severity and are fixed on this branch:

  • The v2 OpenAPI entries for the three Discord writes didn't say a primary profile is required. Fixed in 1b114ce: they now carry the same kind of Description that createPersonalAPIKey has.
  • MayManageDiscordNotifications duplicated MayCreatePersonalAPIKey. Fixed in aa15cdd: both call one helper in household.go.

A Codex (gpt-6.1-sol) adversarial round found no defects.

Verification

On a disposable sandbox, using the same database for both builds:

  • On the merge base, a secondary profile on a member account, a secondary profile on the admin account, and a member session with no profile could all change the mode, unlink, and start a new link on /api/v1 and /api/v2.
  • On the head, those writes return v1 403 forbidden or v2 403 permission_denied. Primary profiles still succeed. A PIN-locked primary succeeds only with a verified X-Profile-Token. A profile-less admin session works until a profile on the household gets a limit. Reads are unchanged.
  • The web settings page shows the Discord controls as read-only to a secondary profile, at desktop and phone widths, and leaves the primary profile's view unchanged.

The internal/api/handlers and internal/apiv2 packages pass in full, the contract artifacts are current, changed-line lint is clean, and the settings web tests and tsc -b pass. No OAuth exchange or Discord message was attempted.

Evidence: https://evidence.siloserver.org/r/silo-server/issue-2752/

Other feedback

  • Visible-change evidence check. It asked for before-and-after API responses. The evidence page now has them for every caller above, on both builds.
  • v1 validation-impact check. It suggested dropping Notifications — Web #1235 from the Validation tasks: line. I kept it. Notifications — Web #1235 C1 walks the web notification preferences and C2 tests opt-out, and the Discord switch on that page is now read-only for a secondary profile, so a validator using one would see a change. Neither task has a recorded pass, so no validated result is affected either way.
  • Earlier ci / Go test failure. TestAdminDefaultChangeReachesEveryViewer failed on main too, and fix(events): deliver administrator default changes to every viewer #2754 fixed it. Main is now merged into this branch.

Validated features

#1234 (Notifications — Server) C1 and #1235 (Notifications — Web) C1 and C2 are all Not run, so this PR changes no recorded pass. I couldn't run the board-wide passed-case query because project-read permission is unavailable.

Clients, Jellyfin compatibility, and docs

Verdict

Fit: 9/10 · Readiness: 9/10 — ready

  • Fit. This closes a household-control gap in a feature that ships for 1.0, using a rule Silo already documents and enforces elsewhere. It adds no new setting or API surface. The v1 change is a narrow bridge fix with a written reason.
  • Readiness. I confirmed the defect and the fix live on both API versions, the two findings are fixed, and the tests and contract checks pass. CI is green on 0d1b7677f.

Review by Claude Code (claude-opus-5-5), with a Codex (gpt-6.1-sol) adversarial round.

@Quick104
Quick104 merged commit cf90805 into main Oct 20, 2026
24 checks passed
@Quick104
Quick104 deleted the fix/discord-destination-household-authority branch October 20, 2026 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working go Pull requests that update go code impact: security Auth, privacy, or permission boundary priority: P0 Fix/merge first: data-loss, security, or widespread breakage size/XL 500–999 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Discord notification changes need household-manager authority

1 participant