Notification settings: per-type admin toggles and per-user mute - #136
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
NotificationSettingssingleton (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 legacyFITCHECK_NOTIFY_REVIEWERS/FITCHECK_REVIEWER_DIGEST/FITCHECK_NOTIFY_PILOTS_STALEDjango 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.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 aNotificationrow created, which also silences any Discord relay of it (e.g. aa-discordnotify).notify()call site intasks.pynow readsNotificationSettings.current()and checksUserNotificationPreference.is_muted()per recipient, so a muted reviewer/pilot is skipped while everyone else in the same loop is unaffected.NotificationSettingsandUserNotificationPreference.Test plan
manage.py test fitcheck- 804 tests green (was 774; +1 existing-suite adaptation, +29 new intest_notification_settings.py)manage.py check- cleanmanage.py makemigrations fitcheck --check --dry-run- no changes beyond migration 0040notify_reviewers_new_submission,send_review_digest,notify_member_decision,recheck_pending_submissions) and assert on actualallianceauth.notifications.models.Notificationrows 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)