summary refs log tree commit diff
path: root/synapse/handlers/room.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-08-27 15:25:21 +0100
committerErik Johnston <erik@matrix.org>2014-08-27 15:25:27 +0100
commit05672a6a8ca66bd2165217c06c5478a06b0cd952 (patch)
tree161acf6cc738bc98ebd5c2a6f6b9d86a1bb34e01 /synapse/handlers/room.py
parentPEP8 tweaks. (diff)
downloadsynapse-05672a6a8ca66bd2165217c06c5478a06b0cd952.tar.xz
Convert get_paginat_rows to use PaginationConfig. This allows people to supply directions.
Diffstat (limited to 'synapse/handlers/room.py')
-rw-r--r--synapse/handlers/room.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py
index bf66d74548..a32c22db33 100644
--- a/synapse/handlers/room.py
+++ b/synapse/handlers/room.py
@@ -22,6 +22,7 @@ from synapse.api.errors import RoomError, StoreError, SynapseError
 from synapse.api.events.room import (
     RoomTopicEvent, RoomMemberEvent, RoomConfigEvent
 )
+from synapse.streams.config import PaginationConfig
 from synapse.util import stringutils
 from ._base import BaseHandler
 
@@ -115,21 +116,18 @@ class MessageHandler(BaseHandler):
 
         data_source = self.hs.get_event_sources().sources[0]
 
-        if pagin_config.from_token:
-            from_token = pagin_config.from_token
-        else:
-            from_token = yield self.hs.get_event_sources().get_current_token()
+        if not pagin_config.from_token:
+            pagin_config.from_token = yield self.hs.get_event_sources().get_current_token()
 
         user = self.hs.parse_userid(user_id)
 
         events, next_token = yield data_source.get_pagination_rows(
-            user, from_token, pagin_config.to_token, pagin_config.limit,
-            room_id
+            user, pagin_config, room_id
         )
 
         chunk = {
             "chunk": [e.get_dict() for e in events],
-            "start": from_token.to_string(),
+            "start": pagin_config.from_token.to_string(),
             "end": next_token.to_string(),
         }
 
@@ -277,8 +275,9 @@ class MessageHandler(BaseHandler):
 
         # FIXME (erikj): Fix this.
         presence_stream = self.hs.get_event_sources().sources[1]
+        pagination_config = PaginationConfig(from_token=now_token)
         presence, _ = yield presence_stream.get_pagination_rows(
-            user, now_token, None, None, None
+            user, pagination_config, None
         )
 
         limit = pagin_config.limit