Aug 18 - Fix customer roles's notification radio buttons issue

This commit is contained in:
2026-08-18 10:21:50 -04:00
parent 515aa07326
commit d8b5ce201d
5 changed files with 131 additions and 20 deletions
+22
View File
@@ -66,6 +66,28 @@ def overrides_for_user(user_id) -> dict:
}
def override_for(user_id, event_type):
"""One account's answer for one event: True, False, or None (inherit).
Used by notify() to enforce the override on EVERY delivery path, not just
matrix broadcasts. Best-effort: any failure returns None (inherit), so a
lookup problem can never silently swallow a notification.
"""
import logging
if not user_id or not event_type:
return None
try:
row = UserNotificationMatrix.query.filter_by(
user_id=user_id, event_type=event_type).first()
return row.enabled if row is not None else None
except Exception as exc:
logging.getLogger(__name__).error(
'USER MATRIX | single override lookup failed | user=%s event=%s | %s',
user_id, event_type, exc,
)
return None
def overrides_for_event(event_type) -> dict:
"""Return {user_id: bool} — every account's override for one event.