MCPcopy Create free account
hub / github.com/Dispatcharr/Dispatcharr / evaluate_conditions

Function evaluate_conditions

core/developer_notifications.py:160–185  ·  view source on GitHub ↗

Evaluate notification conditions for a user. All conditions must pass (AND logic).

(conditions: list[str] | str | None, user)

Source from the content-addressed store, hash-verified

158# ─────────────────────────────
159
160def evaluate_conditions(conditions: list[str] | str | None, user) -> bool:
161 """
162 Evaluate notification conditions for a user.
163 All conditions must pass (AND logic).
164 """
165 if not conditions:
166 return True
167
168 # Normalize to list
169 if isinstance(conditions, str):
170 conditions = [conditions]
171
172 for condition in conditions:
173 if condition not in CONDITION_CHECKS:
174 logger.warning(f"Unknown condition: {condition}")
175 continue
176
177 try:
178 if not CONDITION_CHECKS[condition](user):
179 return False
180 except Exception as e:
181 logger.error(f"Error evaluating condition {condition}: {e}")
182 # On error, skip this condition (fail open)
183 continue
184
185 return True
186
187
188def should_show_notification(notification_data: dict, user) -> bool:

Callers 3

get_querysetMethod · 0.90
should_show_notificationFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected