summary refs log tree commit diff
path: root/synapse/state.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-10-30 17:00:11 +0000
committerErik Johnston <erik@matrix.org>2014-10-30 17:00:11 +0000
commit12ce441e67a40bb73ac5aca0283c2fe4afac4021 (patch)
tree0a4b6d32dc2a7f149153ad7868d5c5e117335859 /synapse/state.py
parentMake federation return the old current state, so that we can use it to do auth (diff)
downloadsynapse-12ce441e67a40bb73ac5aca0283c2fe4afac4021.tar.xz
Convert event ids to be of the form :example.com
Diffstat (limited to 'synapse/state.py')
-rw-r--r--synapse/state.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/synapse/state.py b/synapse/state.py
index a59688e3b4..414701b272 100644
--- a/synapse/state.py
+++ b/synapse/state.py
@@ -16,8 +16,10 @@
 
 from twisted.internet import defer
 
-from synapse.federation.pdu_codec import encode_event_id, decode_event_id
 from synapse.util.logutils import log_function
+from synapse.util.async import run_on_reactor
+
+from synapse.types import EventID
 
 from collections import namedtuple
 
@@ -43,6 +45,7 @@ class StateHandler(object):
         self.store = hs.get_datastore()
         self._replication = hs.get_replication_layer()
         self.server_name = hs.hostname
+        self.hs = hs
 
     @defer.inlineCallbacks
     @log_function
@@ -77,15 +80,17 @@ class StateHandler(object):
         current_state = snapshot.prev_state_pdu
 
         if current_state:
-            event.prev_state = encode_event_id(
-                current_state.pdu_id, current_state.origin
-            )
+            event.prev_state = EventID.create(
+                current_state.pdu_id, current_state.origin, self.hs
+            ).to_string()
 
         # TODO check current_state to see if the min power level is less
         # than the power level of the user
         # power_level = self._get_power_level_for_event(event)
 
-        pdu_id, origin = decode_event_id(event.event_id, self.server_name)
+        e_id = self.hs.parse_eventid(event.event_id)
+        pdu_id = e_id.localpart
+        origin = e_id.domain
 
         yield self.store.update_current_state(
             pdu_id=pdu_id,
@@ -129,6 +134,8 @@ class StateHandler(object):
     @defer.inlineCallbacks
     @log_function
     def annotate_state_groups(self, event, old_state=None):
+        yield run_on_reactor()
+
         if old_state:
             event.state_group = None
             event.old_state_events = old_state