summary refs log tree commit diff
path: root/synapse/push/bulk_push_rule_evaluator.py
diff options
context:
space:
mode:
authorDavid Baker <dave@matrix.org>2017-10-10 15:23:00 +0100
committerDavid Baker <dave@matrix.org>2017-10-10 15:23:00 +0100
commit0f1eb3e914a1e47e441bd8bfb7d523882646fb6e (patch)
treeddac381da32915a648d3e1985efa08f78658e31c /synapse/push/bulk_push_rule_evaluator.py
parentThere was already a constant for this (diff)
downloadsynapse-0f1eb3e914a1e47e441bd8bfb7d523882646fb6e.tar.xz
Use notification levels in power_levels
Rather than making the condition directly require a specific power
level. This way the level require to notify a room can be configured
per room.
Diffstat (limited to 'synapse/push/bulk_push_rule_evaluator.py')
-rw-r--r--synapse/push/bulk_push_rule_evaluator.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/synapse/push/bulk_push_rule_evaluator.py b/synapse/push/bulk_push_rule_evaluator.py
index adc99bd4f6..db07a97a94 100644
--- a/synapse/push/bulk_push_rule_evaluator.py
+++ b/synapse/push/bulk_push_rule_evaluator.py
@@ -113,7 +113,7 @@ class BulkPushRuleEvaluator(object):
         )
 
     @defer.inlineCallbacks
-    def _get_sender_power_level(self, event, context):
+    def _get_power_levels_and_sender_level(self, event, context):
         pl_event_id = context.prev_state_ids.get(POWER_KEY)
         if pl_event_id:
             # fastpath: if there's a power level event, that's all we need, and
@@ -129,7 +129,9 @@ class BulkPushRuleEvaluator(object):
                 (e.type, e.state_key): e for e in auth_events.itervalues()
             }
 
-        defer.returnValue(get_user_power_level(event.sender, auth_events))
+        sender_level = get_user_power_level(event.sender, auth_events)
+
+        defer.returnValue((auth_events[POWER_KEY].content, sender_level))
 
     @defer.inlineCallbacks
     def action_for_event_by_user(self, event, context):
@@ -146,10 +148,10 @@ class BulkPushRuleEvaluator(object):
             event, context
         )
 
-        sender_power_level = yield self._get_sender_power_level(event, context)
+        (power_levels, sender_power_level) = yield self._get_power_levels_and_sender_level(event, context)
 
         evaluator = PushRuleEvaluatorForEvent(
-            event, len(room_members), sender_power_level
+            event, len(room_members), sender_power_level, power_levels,
         )
 
         condition_cache = {}