Skip to content

Notification settings: per-type admin toggles and per-user mute - #136

Merged
TrueMessenger merged 1 commit into
mainfrom
feat/notification-settings
Jul 8, 2026
Merged

TrueMessenger merged 1 commit into
mainfrom
feat/notification-settings

Conversation

@TrueMessenger

Copy link
Copy Markdown
Owner

Summary

  • Admin-tunable NotificationSettings singleton (Settings -> Notifications): one on/off switch per notification type Fit Check emits - reviewer pings on new submissions, the reviewer digest, pilot approve/reject decisions (human review or a doctrine's "approved by rule" auto-approval), and pilot stale-fit notices. The legacy FITCHECK_NOTIFY_REVIEWERS / FITCHECK_REVIEWER_DIGEST / FITCHECK_NOTIFY_PILOTS_STALE Django settings now only seed these toggles' defaults the first time the row is created, so an existing install's configured behaviour survives the upgrade; after that the settings page is authoritative.
  • Per-user UserNotificationPreference.mute_all: a pilot can mute every Fit Check notification for their own account from a toggle on the Pilot Fittings page. A muted user simply never gets a Notification row created, which also silences any Discord relay of it (e.g. aa-discordnotify).
  • Every notify() call site in tasks.py now reads NotificationSettings.current() and checks UserNotificationPreference.is_muted() per recipient, so a muted reviewer/pilot is skipped while everyone else in the same loop is unaffected.
  • Migration 0040 adds NotificationSettings and UserNotificationPreference.

Test plan

  • manage.py test fitcheck - 804 tests green (was 774; +1 existing-suite adaptation, +29 new in test_notification_settings.py)
  • manage.py check - clean
  • manage.py makemigrations fitcheck --check --dry-run - no changes beyond migration 0040
  • New tests drive the real tasks (notify_reviewers_new_submission, send_review_digest, notify_member_decision, recheck_pending_submissions) and assert on actual allianceauth.notifications.models.Notification rows for each toggle off/on, the legacy-setting seeding path, the settings page (permission gate + GET/POST), and the mute toggle endpoint (login/permission required, own-row-only, unchecked-checkbox unmutes)

Adds an admin-tunable NotificationSettings singleton (Settings ->
Notifications) with one on/off switch per Fit Check notification type:
reviewer pings on new submissions, the reviewer digest, pilot
approve/reject decisions (covers both a reviewer's decision and a
doctrine's "approved by rule" auto-approval), and pilot stale-fit
notices. The legacy FITCHECK_NOTIFY_REVIEWERS / FITCHECK_REVIEWER_DIGEST
/ FITCHECK_NOTIFY_PILOTS_STALE Django settings now only seed these
toggles' defaults the first time the row is created, preserving existing
installs' configured behaviour; after that the settings page is
authoritative.

Every notify() call site in tasks.py now reads NotificationSettings
instead of the module-level constants, and every notification loop
checks a new per-user UserNotificationPreference.mute_all - a muted
user simply never gets a Notification row created, which also silences
any Discord relay of it. Pilots can mute every Fit Check notification
for their own account from a toggle on the Pilot Fittings page.

Also unifies the two notify() branches in recheck_pending_submissions
(the rich stale-diff notice and the plain verdict-changed fallback)
under the single notify_pilots_stale toggle, since both describe the
same logical event.

Migration 0040 adds NotificationSettings and UserNotificationPreference.
@TrueMessenger
TrueMessenger merged commit a5ac93f into main Jul 8, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant