summary refs log tree commit diff
path: root/synapse/push
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2018-02-20 11:30:54 +0000
committerErik Johnston <erik@matrix.org>2018-02-20 11:33:07 +0000
commit6ff8c87484d13c00fddc87b0bcc3f4cd691c81ff (patch)
tree428122fb8903b11b9fe6a982a8a7b272758326c2 /synapse/push
parentMerge pull request #2888 from bachp/pynacl-1.2.1 (diff)
downloadsynapse-6ff8c87484d13c00fddc87b0bcc3f4cd691c81ff.tar.xz
Batch inserts into event_push_actions_staging
Diffstat (limited to 'synapse/push')
-rw-r--r--synapse/push/bulk_push_rule_evaluator.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/synapse/push/bulk_push_rule_evaluator.py b/synapse/push/bulk_push_rule_evaluator.py
index bf4f1c5836..64e9a1da57 100644
--- a/synapse/push/bulk_push_rule_evaluator.py
+++ b/synapse/push/bulk_push_rule_evaluator.py
@@ -144,6 +144,7 @@ class BulkPushRuleEvaluator(object):
             Deferred
         """
         rules_by_user = yield self._get_rules_for_event(event, context)
+        actions_by_user = {}
 
         room_members = yield self.store.get_joined_users_from_context(
             event, context
@@ -189,14 +190,16 @@ class BulkPushRuleEvaluator(object):
                 if matches:
                     actions = [x for x in rule['actions'] if x != 'dont_notify']
                     if actions and 'notify' in actions:
-                        # Push rules say we should notify the user of this event,
-                        # so we mark it in the DB in the staging area. (This
-                        # will then get handled when we persist the event)
-                        yield self.store.add_push_actions_to_staging(
-                            event.event_id, uid, actions,
-                        )
+                        actions_by_user[uid] = actions
                     break
 
+        # Push rules say we should notify the user of this event,
+        # so we mark it in the DB in the staging area. (This
+        # will then get handled when we persist the event)
+        yield self.store.add_push_actions_to_staging(
+            event.event_id, actions_by_user,
+        )
+
 
 def _condition_checker(evaluator, conditions, uid, display_name, cache):
     for cond in conditions: