summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2018-03-14 18:43:38 +0000
committerErik Johnston <erik@matrix.org>2018-03-14 18:43:38 +0000
commitdbbaab7de79c0d542cd0e9256e0c95085af81e8d (patch)
tree2390d2c70823610d45831c7d9b65a84efb7250b2 /synapse
parentAdd concept of StatelessEventContext (diff)
downloadsynapse-erikj/stateless_contexts.tar.xz
Diffstat (limited to 'synapse')
-rw-r--r--synapse/handlers/message.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py
index 4f97c8db79..90c01f6c17 100644
--- a/synapse/handlers/message.py
+++ b/synapse/handlers/message.py
@@ -20,6 +20,7 @@ from synapse.api.constants import EventTypes, Membership
 from synapse.api.errors import AuthError, Codes, SynapseError
 from synapse.crypto.event_signing import add_hashes_and_signatures
 from synapse.events.utils import serialize_event
+from synapse.events.snapshot import EventContext
 from synapse.events.validator import EventValidator
 from synapse.types import (
     UserID, RoomAlias, RoomStreamToken,
@@ -665,7 +666,7 @@ class EventCreationHandler(object):
         Args:
             requester (Requester)
             event (FrozenEvent)
-            context (EventContext)
+            context (StatelessEventContext)
             ratelimit (bool)
             extra_users (list(UserID)): Any extra users to notify about event
         """
@@ -763,9 +764,18 @@ class EventCreationHandler(object):
                         e.sender == event.sender
                     )
 
+                # We get the current state at the event. If we have a full
+                # EventContext, use it, otherwise we hit the DB.
+                if isinstance(context, EventContext):
+                    current_state_ids = context.current_state_ids
+                else:
+                    current_state_ids = yield self.store.get_state_ids_for_group(
+                        context.state_group,
+                    )
+
                 state_to_include_ids = [
                     e_id
-                    for k, e_id in context.current_state_ids.iteritems()
+                    for k, e_id in current_state_ids.iteritems()
                     if k[0] in self.hs.config.room_invite_state_types
                     or k == (EventTypes.Member, event.sender)
                 ]