Add test for filtering

This commit is contained in:
Kovid Goyal
2024-07-28 09:15:18 +05:30
parent 67410c317f
commit 59c175f312
2 changed files with 18 additions and 1 deletions

View File

@@ -685,11 +685,15 @@ class NotificationManager:
return False
return True
@property
def filter_rules(self) -> Iterator[str]:
return iter(get_options().filter_notification.keys())
def is_notification_filtered(self, cmd: NotificationCommand) -> bool:
if self.filter_script(cmd):
self.log(f'Notification {cmd.title!r} filtered out by script')
return True
for rule in get_options().filter_notification:
for rule in self.filter_rules:
if cmd.matches_rule(rule):
self.log(f'Notification {cmd.title!r} filtered out by filter_notification rule: {rule}')
return True