Determine if a notification should be shown to a specific user. Checks version range, user level, and conditions.
(notification_data: dict, user)
| 186 | |
| 187 | |
| 188 | def should_show_notification(notification_data: dict, user) -> bool: |
| 189 | """ |
| 190 | Determine if a notification should be shown to a specific user. |
| 191 | Checks version range, user level, and conditions. |
| 192 | """ |
| 193 | # Check version range |
| 194 | if not is_version_in_range( |
| 195 | __version__, |
| 196 | notification_data.get('min_version'), |
| 197 | notification_data.get('max_version') |
| 198 | ): |
| 199 | return False |
| 200 | |
| 201 | # Check user level |
| 202 | user_level = notification_data.get('user_level', 'all') |
| 203 | if user_level == 'admin' and getattr(user, 'user_level', 0) < 10: |
| 204 | return False |
| 205 | |
| 206 | # Check conditions |
| 207 | conditions = notification_data.get('condition', []) |
| 208 | if not evaluate_conditions(conditions, user): |
| 209 | return False |
| 210 | |
| 211 | return True |
| 212 | |
| 213 | |
| 214 | # ───────────────────────────── |
nothing calls this directly
no test coverage detected