summary refs log tree commit diff
path: root/synapse/handlers
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2015-11-13 10:31:15 +0000
committerRichard van der Hoff <richard@matrix.org>2015-11-13 10:31:15 +0000
commit5dea4d37d160e5766aac6f1723a8b485c5b6c211 (patch)
tree7eee70452ba3740f393a14924e2fb1f9055d9e3c /synapse/handlers
parentMerge pull request #369 from matrix-org/daniel/guestnonevents (diff)
downloadsynapse-5dea4d37d160e5766aac6f1723a8b485c5b6c211.tar.xz
Update some comments
Add a couple of type annotations, docstrings, and other comments, in the
interest of keeping track of what types I have.

Merged from pull request #370.
Diffstat (limited to 'synapse/handlers')
-rw-r--r--synapse/handlers/_base.py6
-rw-r--r--synapse/handlers/sync.py34
2 files changed, 30 insertions, 10 deletions
diff --git a/synapse/handlers/_base.py b/synapse/handlers/_base.py
index f4ade1f594..6519f183df 100644
--- a/synapse/handlers/_base.py
+++ b/synapse/handlers/_base.py
@@ -29,6 +29,12 @@ logger = logging.getLogger(__name__)
 
 
 class BaseHandler(object):
+    """
+    Common base class for the event handlers.
+
+    :type store: synapse.storage.events.StateStore
+    :type state_handler: synapse.state.StateHandler
+    """
 
     def __init__(self, hs):
         self.store = hs.get_datastore()
diff --git a/synapse/handlers/sync.py b/synapse/handlers/sync.py
index 492c1c17d5..ed93e5a2df 100644
--- a/synapse/handlers/sync.py
+++ b/synapse/handlers/sync.py
@@ -47,9 +47,9 @@ class TimelineBatch(collections.namedtuple("TimelineBatch", [
 
 
 class JoinedSyncResult(collections.namedtuple("JoinedSyncResult", [
-    "room_id",
-    "timeline",
-    "state",
+    "room_id",           # str
+    "timeline",          # TimelineBatch
+    "state",             # list[FrozenEvent]
     "ephemeral",
     "private_user_data",
 ])):
@@ -68,9 +68,9 @@ class JoinedSyncResult(collections.namedtuple("JoinedSyncResult", [
 
 
 class ArchivedSyncResult(collections.namedtuple("JoinedSyncResult", [
-    "room_id",
-    "timeline",
-    "state",
+    "room_id",            # str
+    "timeline",           # TimelineBatch
+    "state",              # list[FrozenEvent]
     "private_user_data",
 ])):
     __slots__ = []
@@ -87,8 +87,8 @@ class ArchivedSyncResult(collections.namedtuple("JoinedSyncResult", [
 
 
 class InvitedSyncResult(collections.namedtuple("InvitedSyncResult", [
-    "room_id",
-    "invite",
+    "room_id",   # str
+    "invite",    # FrozenEvent: the invite event
 ])):
     __slots__ = []
 
@@ -507,6 +507,9 @@ class SyncHandler(BaseHandler):
     @defer.inlineCallbacks
     def load_filtered_recents(self, room_id, sync_config, now_token,
                               since_token=None):
+        """
+        :returns a Deferred TimelineBatch
+        """
         limited = True
         recents = []
         filtering_factor = 2
@@ -680,8 +683,13 @@ class SyncHandler(BaseHandler):
     def compute_state_delta(self, since_token, previous_state, current_state):
         """ Works out the differnce in state between the current state and the
         state the client got when it last performed a sync.
-        Returns:
-            A list of events.
+
+        :param str since_token: the point we are comparing against
+        :param list[synapse.events.FrozenEvent] previous_state: the state to
+            compare to
+        :param list[synapse.events.FrozenEvent] current_state: the new state
+
+        :returns: A list of events.
         """
         # TODO(mjark) Check if the state events were received by the server
         # after the previous sync, since we need to include those state
@@ -696,6 +704,12 @@ class SyncHandler(BaseHandler):
 
     @defer.inlineCallbacks
     def check_joined_room(self, sync_config, room_id, state_delta):
+        """
+        Check if the user has just joined the given room. If so, return the
+        full state for the room, instead of the delta since the last sync.
+
+        :returns A deferred Tuple (state_delta, limited)
+        """
         joined = False
         limited = False
         for event in state_delta: