summary refs log tree commit diff
path: root/synapse/handlers
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-11-07 16:03:31 +0000
committerErik Johnston <erik@matrix.org>2014-11-07 16:03:31 +0000
commit07286a73b179c7b3888f7cbf15dcf7c4f5a0c3a3 (patch)
treea9c62914ed34a232cdee3d25dcc83d8381d4057b /synapse/handlers
parentAdd '/event_auth/' federation api (diff)
downloadsynapse-07286a73b179c7b3888f7cbf15dcf7c4f5a0c3a3.tar.xz
Use current state to get room hosts, rather than querying the database
Diffstat (limited to 'synapse/handlers')
-rw-r--r--synapse/handlers/_base.py18
-rw-r--r--synapse/handlers/federation.py21
2 files changed, 32 insertions, 7 deletions
diff --git a/synapse/handlers/_base.py b/synapse/handlers/_base.py
index 9dc2fc2e0f..07a8464107 100644
--- a/synapse/handlers/_base.py
+++ b/synapse/handlers/_base.py
@@ -18,6 +18,8 @@ from twisted.internet import defer
 from synapse.api.errors import LimitExceededError
 from synapse.util.async import run_on_reactor
 from synapse.crypto.event_signing import add_hashes_and_signatures
+from synapse.api.events.room import RoomMemberEvent
+from synapse.api.constants import Membership
 
 import logging
 
@@ -95,9 +97,19 @@ class BaseHandler(object):
 
         destinations = set(extra_destinations)
         # Send a PDU to all hosts who have joined the room.
-        destinations.update((yield self.store.get_joined_hosts_for_room(
-            event.room_id
-        )))
+
+        for k, s in event.state_events.items():
+            try:
+                if k[0] == RoomMemberEvent.TYPE:
+                    if s.content["membership"] == Membership.JOIN:
+                        destinations.add(
+                            self.hs.parse_userid(s.state_key).domain
+                        )
+            except:
+                logger.warn(
+                    "Failed to get destination from event %s", s.event_id
+                )
+
         event.destinations = list(destinations)
 
         self.notifier.on_new_room_event(event, extra_users=extra_users)
diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py
index ce65bbcd62..7e10583902 100644
--- a/synapse/handlers/federation.py
+++ b/synapse/handlers/federation.py
@@ -376,10 +376,23 @@ class FederationHandler(BaseHandler):
                     "user_joined_room", user=user, room_id=event.room_id
                 )
 
-        new_pdu = self.pdu_codec.pdu_from_event(event);
-        new_pdu.destinations = yield self.store.get_joined_hosts_for_room(
-            event.room_id
-        )
+        new_pdu = self.pdu_codec.pdu_from_event(event)
+
+        destinations = set()
+
+        for k, s in event.state_events.items():
+            try:
+                if k[0] == RoomMemberEvent.TYPE:
+                    if s.content["membership"] == Membership.JOIN:
+                        destinations.add(
+                            self.hs.parse_userid(s.state_key).domain
+                        )
+            except:
+                logger.warn(
+                    "Failed to get destination from event %s", s.event_id
+                )
+
+        new_pdu.destinations = list(destinations)
 
         yield self.replication_layer.send_pdu(new_pdu)