summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--synapse/push/bulk_push_rule_evaluator.py15
-rw-r--r--synapse/storage/receipts.py2
2 files changed, 11 insertions, 6 deletions
diff --git a/synapse/push/bulk_push_rule_evaluator.py b/synapse/push/bulk_push_rule_evaluator.py
index 23fde7508e..a9dcf8b083 100644
--- a/synapse/push/bulk_push_rule_evaluator.py
+++ b/synapse/push/bulk_push_rule_evaluator.py
@@ -21,7 +21,7 @@ from twisted.internet import defer
 from .baserules import list_with_base_rules
 from .push_rule_evaluator import PushRuleEvaluatorForEvent
 
-from synapse.api.constants import EventTypes
+from synapse.api.constants import EventTypes, Membership
 from synapse.visibility import filter_events_for_clients
 from synapse.util.logutils import log_duration
 
@@ -76,7 +76,7 @@ def _get_rules(room_id, user_ids, store):
 
 
 @defer.inlineCallbacks
-def evaluator_for_event(event, hs, store):
+def evaluator_for_event(event, hs, store, current_state):
     room_id = event.room_id
 
     # users in the room who have pushers need to get push rules run because
@@ -90,8 +90,10 @@ def evaluator_for_event(event, hs, store):
     # sent a read receipt into the room.
 
     with log_duration("get_users_in_room"):
-        all_in_room = yield store.get_users_in_room(room_id)
-        all_in_room = set(all_in_room)
+        all_in_room = set(
+            e.state_key for e in current_state.values()
+            if e.type == EventTypes.Member and e.membership == Membership.JOIN
+        )
 
     with log_duration("get_receipts_for_room"):
         users_with_receipts = yield store.get_users_with_read_receipts_in_room(room_id)
@@ -153,7 +155,10 @@ class BulkPushRuleEvaluator:
             self.store, user_tuples, [event], {event.event_id: current_state}
         )
 
-        room_members = yield self.store.get_users_in_room(self.room_id)
+        room_members = set(
+            e.state_key for e in current_state.values()
+            if e.type == EventTypes.Member and e.membership == Membership.JOIN
+        )
 
         evaluator = PushRuleEvaluatorForEvent(event, len(room_members))
 
diff --git a/synapse/storage/receipts.py b/synapse/storage/receipts.py
index ba806f1b03..964f30dff7 100644
--- a/synapse/storage/receipts.py
+++ b/synapse/storage/receipts.py
@@ -44,7 +44,7 @@ class ReceiptsStore(SQLBaseStore):
         if receipt_type != "m.read":
             return
 
-        # XXX: ObservableDeferred?!
+        # Returns an ObservableDeferred
         res = self.get_users_with_read_receipts_in_room.cache.get((room_id,), None)
 
         if res and res.called and user_id in res.result: