summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
Diffstat (limited to 'synapse')
-rw-r--r--synapse/handlers/_base.py4
-rw-r--r--synapse/handlers/federation.py4
-rw-r--r--synapse/push/action_generator.py7
-rw-r--r--synapse/push/bulk_push_rule_evaluator.py2
-rw-r--r--synapse/storage/event_actions.py2
-rw-r--r--synapse/storage/push_rule.py6
-rw-r--r--synapse/storage/registration.py12
7 files changed, 12 insertions, 25 deletions
diff --git a/synapse/handlers/_base.py b/synapse/handlers/_base.py
index 24c4c62698..938eb29de7 100644
--- a/synapse/handlers/_base.py
+++ b/synapse/handlers/_base.py
@@ -267,8 +267,8 @@ class BaseHandler(object):
             event, context=context
         )
 
-        action_generator = ActionGenerator(self.hs, self.store)
-        yield action_generator.handle_event(serialize_event(
+        action_generator = ActionGenerator(self.store)
+        yield action_generator.handle_push_actions_for_event(serialize_event(
             event, self.clock.time_msec()
         ))
 
diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py
index 0b1221deb5..764709b424 100644
--- a/synapse/handlers/federation.py
+++ b/synapse/handlers/federation.py
@@ -245,8 +245,8 @@ class FederationHandler(BaseHandler):
                     yield user_joined_room(self.distributor, user, event.room_id)
 
         if not backfilled and not event.internal_metadata.is_outlier():
-            action_generator = ActionGenerator(self.hs, self.store)
-            yield action_generator.handle_event(serialize_event(
+            action_generator = ActionGenerator(self.store)
+            yield action_generator.handle_push_actions_for_event(serialize_event(
                 event, self.clock.time_msec())
             )
 
diff --git a/synapse/push/action_generator.py b/synapse/push/action_generator.py
index 00f518f609..4ab5d9e1b8 100644
--- a/synapse/push/action_generator.py
+++ b/synapse/push/action_generator.py
@@ -23,8 +23,7 @@ logger = logging.getLogger(__name__)
 
 
 class ActionGenerator:
-    def __init__(self, hs, store):
-        self.hs = hs
+    def __init__(self, store):
         self.store = store
         # really we want to get all user ids and all profile tags too,
         # since we want the actions for each profile tag for every user and
@@ -34,9 +33,9 @@ class ActionGenerator:
         # tag (ie. we just need all the users).
 
     @defer.inlineCallbacks
-    def handle_event(self, event):
+    def handle_push_actions_for_event(self, event):
         bulk_evaluator = yield bulk_push_rule_evaluator.evaluator_for_room_id(
-            event['room_id'], self.hs, self.store
+            event['room_id'], self.store
         )
 
         actions_by_user = bulk_evaluator.action_for_event_by_user(event)
diff --git a/synapse/push/bulk_push_rule_evaluator.py b/synapse/push/bulk_push_rule_evaluator.py
index c489bfc8d4..1c4e54ba44 100644
--- a/synapse/push/bulk_push_rule_evaluator.py
+++ b/synapse/push/bulk_push_rule_evaluator.py
@@ -33,7 +33,7 @@ def decode_rule_json(rule):
 
 
 @defer.inlineCallbacks
-def evaluator_for_room_id(room_id, hs, store):
+def evaluator_for_room_id(room_id, store):
     users = yield store.get_users_in_room(room_id)
     rules_by_user = yield store.bulk_get_push_rules(users)
     rules_by_user = {
diff --git a/synapse/storage/event_actions.py b/synapse/storage/event_actions.py
index 3efa445c18..fa9cbe71ee 100644
--- a/synapse/storage/event_actions.py
+++ b/synapse/storage/event_actions.py
@@ -1,5 +1,5 @@
 # -*- coding: utf-8 -*-
-# Copyright 2014 OpenMarket Ltd
+# Copyright 2015 OpenMarket Ltd
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
diff --git a/synapse/storage/push_rule.py b/synapse/storage/push_rule.py
index 9dec4aa685..7c5123d644 100644
--- a/synapse/storage/push_rule.py
+++ b/synapse/storage/push_rule.py
@@ -62,12 +62,12 @@ class PushRuleStore(SQLBaseStore):
         def f(txn, user_ids_to_fetch):
             sql = (
                 "SELECT " +
-                ",".join(map(lambda x: "pr."+x, PushRuleTable.fields)) +
+                ",".join("pr."+x for x in PushRuleTable.fields) +
                 " FROM " + PushRuleTable.table_name + " pr " +
                 " LEFT JOIN " + PushRuleEnableTable.table_name + " pre " +
                 " ON pr.user_name = pre.user_name and pr.rule_id = pre.rule_id " +
                 " WHERE pr.user_name " +
-                " IN (" + ",".join(["?" for _ in user_ids_to_fetch]) + ")"
+                " IN (" + ",".join("?" for _ in user_ids_to_fetch) + ")"
                 " AND (pre.enabled is null or pre.enabled = 1)"
                 " ORDER BY pr.user_name, pr.priority_class DESC, pr.priority DESC"
             )
@@ -78,7 +78,7 @@ class PushRuleStore(SQLBaseStore):
 
         batch_start = 0
         while batch_start < len(user_ids):
-            batch_end = max(len(user_ids), batch_size)
+            batch_end = min(len(user_ids), batch_size)
             batch_user_ids = user_ids[batch_start:batch_end]
             batch_start = batch_end
 
diff --git a/synapse/storage/registration.py b/synapse/storage/registration.py
index 4676f225b9..09a05b08ef 100644
--- a/synapse/storage/registration.py
+++ b/synapse/storage/registration.py
@@ -292,18 +292,6 @@ class RegistrationStore(SQLBaseStore):
         defer.returnValue(None)
 
     @defer.inlineCallbacks
-    def get_all_user_ids(self):
-        """Returns all user ids registered on this homeserver"""
-        return self.runInteraction(
-            "get_all_user_ids",
-            self._get_all_user_ids_txn
-        )
-
-    def _get_all_user_ids_txn(self, txn):
-        txn.execute("SELECT name from users")
-        return [r[0] for r in txn.fetchall()]
-
-    @defer.inlineCallbacks
     def count_all_users(self):
         """Counts all users registered on the homeserver."""
         def _count_users(txn):