summary refs log tree commit diff
path: root/synapse/handlers
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-12-16 18:35:46 +0000
committerErik Johnston <erik@matrix.org>2014-12-16 18:35:46 +0000
commitf76269392b17d2dbabc85579300d9eef9a559d4e (patch)
tree94036377e17568e6983d6aeb2a73b827a277a580 /synapse/handlers
parentUse is_outlier() so that we don't get AttributeError (diff)
parentMerge branch 'release-v0.6.0' into develop (diff)
downloadsynapse-f76269392b17d2dbabc85579300d9eef9a559d4e.tar.xz
Merge branch 'develop' of github.com:matrix-org/synapse into release-v0.6.0
Conflicts:
	synapse/state.py
Diffstat (limited to 'synapse/handlers')
-rw-r--r--synapse/handlers/_base.py13
-rw-r--r--synapse/handlers/directory.py1
-rw-r--r--synapse/handlers/federation.py21
-rw-r--r--synapse/handlers/message.py38
-rw-r--r--synapse/handlers/typing.py4
5 files changed, 11 insertions, 66 deletions
diff --git a/synapse/handlers/_base.py b/synapse/handlers/_base.py
index af8eb5f0f5..97ebd98917 100644
--- a/synapse/handlers/_base.py
+++ b/synapse/handlers/_base.py
@@ -20,8 +20,6 @@ from synapse.util.async import run_on_reactor
 from synapse.crypto.event_signing import add_hashes_and_signatures
 from synapse.api.constants import Membership, EventTypes
 
-from synapse.events.snapshot import EventContext
-
 import logging
 
 
@@ -61,8 +59,6 @@ class BaseHandler(object):
     def _create_new_client_event(self, builder):
         yield run_on_reactor()
 
-        context = EventContext()
-
         latest_ret = yield self.store.get_latest_events_in_room(
             builder.room_id,
         )
@@ -78,14 +74,11 @@ class BaseHandler(object):
         builder.depth = depth
 
         state_handler = self.state_handler
-        ret = yield state_handler.annotate_context_with_state(
-            builder,
-            context,
-        )
-        prev_state = ret
+
+        context = yield state_handler.compute_event_context(builder)
 
         if builder.is_state():
-            builder.prev_state = prev_state
+            builder.prev_state = context.prev_state_events
 
         yield self.auth.add_auth_events(builder, context)
 
diff --git a/synapse/handlers/directory.py b/synapse/handlers/directory.py
index 404baea796..66d3b533d9 100644
--- a/synapse/handlers/directory.py
+++ b/synapse/handlers/directory.py
@@ -156,4 +156,3 @@ class DirectoryHandler(BaseHandler):
             "sender": user_id,
             "content": {"aliases": aliases},
         })
-
diff --git a/synapse/handlers/federation.py b/synapse/handlers/federation.py
index 16a104c0e2..4aec3563ac 100644
--- a/synapse/handlers/federation.py
+++ b/synapse/handlers/federation.py
@@ -17,7 +17,6 @@
 
 from ._base import BaseHandler
 
-from synapse.events.snapshot import EventContext
 from synapse.events.utils import prune_event
 from synapse.api.errors import (
     AuthError, FederationError, SynapseError, StoreError,
@@ -202,7 +201,7 @@ class FederationHandler(BaseHandler):
                 e.msg,
                 affected=event.event_id,
             )
-            
+
         # if we're receiving valid events from an origin,
         # it's probably a good idea to mark it as not in retry-state
         # for sending (although this is a bit of a leap)
@@ -260,12 +259,9 @@ class FederationHandler(BaseHandler):
             event = pdu
 
             # FIXME (erikj): Not sure this actually works :/
-            context = EventContext()
-            yield self.state_handler.annotate_context_with_state(event, context)
+            context = yield self.state_handler.compute_event_context(event)
 
-            events.append(
-                (event, context)
-            )
+            events.append((event, context))
 
             yield self.store.persist_event(
                 event,
@@ -547,8 +543,6 @@ class FederationHandler(BaseHandler):
         """
         event = pdu
 
-        context = EventContext()
-
         event.internal_metadata.outlier = True
 
         event.signatures.update(
@@ -559,7 +553,7 @@ class FederationHandler(BaseHandler):
             )
         )
 
-        yield self.state_handler.annotate_context_with_state(event, context)
+        context = yield self.state_handler.compute_event_context(event)
 
         yield self.store.persist_event(
             event,
@@ -685,17 +679,14 @@ class FederationHandler(BaseHandler):
     @defer.inlineCallbacks
     def _handle_new_event(self, event, state=None, backfilled=False,
                           current_state=None, fetch_missing=True):
-        context = EventContext()
 
         logger.debug(
             "_handle_new_event: Before annotate: %s, sigs: %s",
             event.event_id, event.signatures,
         )
 
-        yield self.state_handler.annotate_context_with_state(
-            event,
-            context,
-            old_state=state
+        context = yield self.state_handler.compute_event_context(
+            event, old_state=state
         )
 
         logger.debug(
diff --git a/synapse/handlers/message.py b/synapse/handlers/message.py
index 7939d2bffa..49c0e98113 100644
--- a/synapse/handlers/message.py
+++ b/synapse/handlers/message.py
@@ -18,8 +18,6 @@ from twisted.internet import defer
 from synapse.api.constants import EventTypes, Membership
 from synapse.api.errors import RoomError
 from synapse.streams.config import PaginationConfig
-from synapse.util.logcontext import PreserveLoggingContext
-
 from synapse.events.validator import EventValidator
 
 from ._base import BaseHandler
@@ -67,35 +65,6 @@ class MessageHandler(BaseHandler):
         defer.returnValue(None)
 
     @defer.inlineCallbacks
-    def send_message(self, event=None, suppress_auth=False):
-        """ Send a message.
-
-        Args:
-            event : The message event to store.
-            suppress_auth (bool) : True to suppress auth for this message. This
-            is primarily so the home server can inject messages into rooms at
-            will.
-        Raises:
-            SynapseError if something went wrong.
-        """
-
-        self.ratelimit(event.user_id)
-        # TODO(paul): Why does 'event' not have a 'user' object?
-        user = self.hs.parse_userid(event.user_id)
-        assert self.hs.is_mine(user), "User must be our own: %s" % (user,)
-
-        snapshot = yield self.store.snapshot_room(event)
-
-        yield self._on_new_room_event(
-            event, snapshot, suppress_auth=suppress_auth
-        )
-
-        with PreserveLoggingContext():
-            self.hs.get_handlers().presence_handler.bump_presence_active_time(
-                user
-            )
-
-    @defer.inlineCallbacks
     def get_messages(self, user_id=None, room_id=None, pagin_config=None,
                      feedback=False):
         """Get messages in a room.
@@ -218,13 +187,6 @@ class MessageHandler(BaseHandler):
         defer.returnValue(None)
 
     @defer.inlineCallbacks
-    def send_feedback(self, event):
-        snapshot = yield self.store.snapshot_room(event)
-
-        # store message in db
-        yield self._on_new_room_event(event, snapshot)
-
-    @defer.inlineCallbacks
     def get_state_events(self, user_id, room_id):
         """Retrieve all state events for a given room.
 
diff --git a/synapse/handlers/typing.py b/synapse/handlers/typing.py
index 77d66f66ff..7626b07280 100644
--- a/synapse/handlers/typing.py
+++ b/synapse/handlers/typing.py
@@ -45,8 +45,8 @@ class TypingNotificationHandler(BaseHandler):
 
         hs.get_distributor().observe("user_left_room", self.user_left_room)
 
-        self._member_typing_until = {} # clock time we expect to stop
-        self._member_typing_timer = {} # deferreds to manage theabove
+        self._member_typing_until = {}  # clock time we expect to stop
+        self._member_typing_timer = {}  # deferreds to manage theabove
 
         # map room IDs to serial numbers
         self._room_serials = {}