summary refs log tree commit diff
path: root/synapse/streams/events.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/streams/events.py
parentPEP8 tweaks. (diff)
downloadsynapse-05672a6a8ca66bd2165217c06c5478a06b0cd952.tar.xz
Convert get_paginat_rows to use PaginationConfig. This allows people to supply directions.
Diffstat (limited to '')
-rw-r--r--synapse/streams/events.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/synapse/streams/events.py b/synapse/streams/events.py
index bf48df5b79..8a84a9d392 100644
--- a/synapse/streams/events.py
+++ b/synapse/streams/events.py
@@ -47,14 +47,19 @@ class RoomEventSource(object):
         return self.store.get_room_events_max_id()
 
     @defer.inlineCallbacks
-    def get_pagination_rows(self, user, from_token, to_token, limit, key):
+    def get_pagination_rows(self, user, pagination_config, key):
+        from_token = pagination_config.from_token
+        to_token = pagination_config.to_token
+        limit = pagination_config.limit
+        direction = pagination_config.direction
+
         to_key = to_token.events_key if to_token else None
 
         events, next_key = yield self.store.paginate_room_events(
             room_id=key,
             from_key=from_token.events_key,
             to_key=to_key,
-            direction='b',
+            direction=direction,
             limit=limit,
             with_feedback=True
         )
@@ -101,7 +106,12 @@ class PresenceSource(object):
         presence = self.hs.get_handlers().presence_handler
         return presence._user_cachemap_latest_serial
 
-    def get_pagination_rows(self, user, from_token, to_token, limit, key):
+    def get_pagination_rows(self, user, pagination_config, key):
+        # TODO (erikj): Does this make sense? Ordering?
+
+        from_token = pagination_config.from_token
+        to_token = pagination_config.to_token
+
         from_key = int(from_token.presence_key)
 
         if to_token:
@@ -167,7 +177,5 @@ class StreamSource(object):
     def get_current_token_part(self):
         raise NotImplementedError("get_current_token_part")
 
-
-class PaginationSource(object):
-    def get_pagination_rows(self, user, from_token, to_token, limit, key):
+    def get_pagination_rows(self, user, pagination_config, key):
         raise NotImplementedError("get_rows")