feat: granular per-mode alert filters (v0.9.3)
Replace coarse milestone/referral suppression with 8 named action categories (vote, presidential, committee_report, calendar, procedural, referral, new_document, new_amendment), each independently togglable per follow mode (Follow / Pocket Veto / Pocket Boost). - notification_utils: categorize_action() replaces is_milestone_action / is_referral_action; _build_payload stores action_category in payload - congress_poller: use categorize_action() in _update_bill_if_changed - notification_dispatcher: _should_dispatch() checks per-mode filter dict from notification_prefs; follow mode looked up before filter check - schemas + api: alert_filters (nested dict) wired through settings GET/PUT endpoints; no DB migration required - frontend: tabbed Alert Filters section (Follow / Pocket Veto / Pocket Boost), each with independent 8-toggle filter set, milestone parent checkbox (indeterminate-aware), Load defaults button, and per-tab Save button Authored-By: Jack Levy
This commit is contained in:
@@ -339,16 +339,13 @@ def _update_bill_if_changed(db, existing: Bill, parsed: dict) -> bool:
|
||||
emit_bill_notification,
|
||||
emit_member_follow_notifications,
|
||||
emit_topic_follow_notifications,
|
||||
is_milestone_action,
|
||||
is_referral_action,
|
||||
categorize_action,
|
||||
)
|
||||
action_text = parsed.get("latest_action_text", "")
|
||||
is_milestone = is_milestone_action(action_text)
|
||||
is_referral = not is_milestone and is_referral_action(action_text)
|
||||
if is_milestone or is_referral:
|
||||
tier = "progress" if is_milestone else "referral"
|
||||
emit_bill_notification(db, existing, "bill_updated", action_text, milestone_tier=tier)
|
||||
emit_member_follow_notifications(db, existing, "bill_updated", action_text, milestone_tier=tier)
|
||||
action_category = categorize_action(action_text)
|
||||
if action_category:
|
||||
emit_bill_notification(db, existing, "bill_updated", action_text, action_category=action_category)
|
||||
emit_member_follow_notifications(db, existing, "bill_updated", action_text, action_category=action_category)
|
||||
# Topic followers — pull tags from the bill's latest brief
|
||||
from app.models.brief import BillBrief
|
||||
latest_brief = (
|
||||
@@ -359,7 +356,7 @@ def _update_bill_if_changed(db, existing: Bill, parsed: dict) -> bool:
|
||||
)
|
||||
topic_tags = latest_brief.topic_tags or [] if latest_brief else []
|
||||
emit_topic_follow_notifications(
|
||||
db, existing, "bill_updated", action_text, topic_tags, milestone_tier=tier
|
||||
db, existing, "bill_updated", action_text, topic_tags, action_category=action_category
|
||||
)
|
||||
return changed
|
||||
|
||||
|
||||
Reference in New Issue
Block a user