summary refs log tree commit diff
path: root/synapse/state.py
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2014-12-16 15:59:17 +0000
committerMark Haines <mark.haines@matrix.org>2014-12-16 15:59:17 +0000
commitc3eae8a88c21cf99b0109ebcb3f0f49714617060 (patch)
tree101a0f911b2ffd19fd1fff71516aba7a9f0e006c /synapse/state.py
parentclean up coding style a bit (diff)
downloadsynapse-c3eae8a88c21cf99b0109ebcb3f0f49714617060.tar.xz
Construct the EventContext in the state handler rather than constructing one and then immediately calling state_handler.annotate_context_with_state
Diffstat (limited to 'synapse/state.py')
-rw-r--r--synapse/state.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/synapse/state.py b/synapse/state.py
index 61b14b939f..551058b510 100644
--- a/synapse/state.py
+++ b/synapse/state.py
@@ -19,6 +19,7 @@ from twisted.internet import defer
 from synapse.util.logutils import log_function
 from synapse.util.async import run_on_reactor
 from synapse.api.constants import EventTypes
+from synapse.events.snapshot import EventContext
 
 from collections import namedtuple
 
@@ -70,7 +71,7 @@ class StateHandler(object):
         defer.returnValue(res[1].values())
 
     @defer.inlineCallbacks
-    def annotate_context_with_state(self, event, context, old_state=None):
+    def compute_event_context(self, event, old_state=None):
         """ Fills out the context with the `current state` of the graph. The
         `current state` here is defined to be the state of the event graph
         just before the event - i.e. it never includes `event`
@@ -80,8 +81,11 @@ class StateHandler(object):
 
         Args:
             event (EventBase)
-            context (EventContext)
+        Returns:
+            an EventContext
         """
+        context = EventContext()
+
         yield run_on_reactor()
 
         if old_state:
@@ -107,7 +111,8 @@ class StateHandler(object):
                     if replaces.event_id != event.event_id:  # Paranoia check
                         event.unsigned["replaces_state"] = replaces.event_id
 
-            defer.returnValue([])
+            context.prev_state_events = []
+            defer.returnValue(context)
 
         if event.is_state():
             ret = yield self.resolve_state_groups(
@@ -145,7 +150,8 @@ class StateHandler(object):
         else:
             context.auth_events = {}
 
-        defer.returnValue(prev_state)
+        context.prev_state_events = prev_state
+        defer.returnValue(context)
 
     @defer.inlineCallbacks
     @log_function