diff options
author | David Baker <dave@matrix.org> | 2015-12-10 18:40:28 +0000 |
---|---|---|
committer | David Baker <dave@matrix.org> | 2015-12-10 18:40:28 +0000 |
commit | 5e909c73d76cd56e3eac91635a99405182dcac3c (patch) | |
tree | 08b13f84598df490b1f92181a446ffad7cddb876 /synapse/push/push_rule_evaluator.py | |
parent | Save event actions to the db (diff) | |
download | synapse-5e909c73d76cd56e3eac91635a99405182dcac3c.tar.xz |
Store nothing instead of ['dont_notify'] for events with no notification required: much as it would be nice to be able to tell between the event not having been processed and there being no notification for it, this isn't worth filling up the table with ['dont_notify'] I think. Consequently treat the empty actions array as dont_notify and filter dont_notify out of the result.
Diffstat (limited to 'synapse/push/push_rule_evaluator.py')
-rw-r--r-- | synapse/push/push_rule_evaluator.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/synapse/push/push_rule_evaluator.py b/synapse/push/push_rule_evaluator.py index 92c7fd048f..420476fd0b 100644 --- a/synapse/push/push_rule_evaluator.py +++ b/synapse/push/push_rule_evaluator.py @@ -43,7 +43,7 @@ def evaluator_for_user_name_and_profile_tag(user_name, profile_tag, room_id, sto class PushRuleEvaluator: - DEFAULT_ACTIONS = ['dont_notify'] + DEFAULT_ACTIONS = [] INEQUALITY_EXPR = re.compile("^([=<>]*)([0-9]*)$") def __init__(self, user_name, profile_tag, raw_rules, enabled_map, room_id, @@ -85,7 +85,7 @@ class PushRuleEvaluator: """ if ev['user_id'] == self.user_name: # let's assume you probably know about messages you sent yourself - defer.returnValue(['dont_notify']) + defer.returnValue([]) room_id = ev['room_id'] @@ -131,6 +131,11 @@ class PushRuleEvaluator: "%s matches for user %s, event %s", r['rule_id'], self.user_name, ev['event_id'] ) + + # filter out dont_notify as we treat an empty actions list + # as dont_notify, and this doesn't take up a row in our database + actions = [x for x in actions if x != 'dont_notify'] + defer.returnValue(actions) logger.info( |