diff options
author | Erik Johnston <erik@matrix.org> | 2014-08-15 15:53:06 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2014-08-15 15:53:06 +0100 |
commit | 8d1f7632095b949d7726dd72fce10224764f3c11 (patch) | |
tree | f8ff59114b36c711e51466e431526546a6296c7b /synapse/handlers | |
parent | Correctly return new token when returning events. Serialize events correctly. (diff) | |
download | synapse-8d1f7632095b949d7726dd72fce10224764f3c11.tar.xz |
Fix pagination to work with new db schema
Diffstat (limited to 'synapse/handlers')
-rw-r--r-- | synapse/handlers/room.py | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py index 9261984b7e..b0b2441b9f 100644 --- a/synapse/handlers/room.py +++ b/synapse/handlers/room.py @@ -97,30 +97,30 @@ class MessageHandler(BaseHandler): self.notifier.on_new_room_event(event, store_id) yield self.hs.get_federation().handle_new_event(event) -# -# @defer.inlineCallbacks -# def get_messages(self, user_id=None, room_id=None, pagin_config=None, -# feedback=False): -# """Get messages in a room. -# -# Args: -# user_id (str): The user requesting messages. -# room_id (str): The room they want messages from. -# pagin_config (synapse.api.streams.PaginationConfig): The pagination -# config rules to apply, if any. -# feedback (bool): True to get compressed feedback with the messages -# Returns: -# dict: Pagination API results -# """ -# yield self.auth.check_joined_room(room_id, user_id) -# -# data_source = [MessagesStreamData(self.hs, room_id=room_id, -# feedback=feedback)] -# event_stream = EventStream(user_id, data_source) -# pagin_config = yield event_stream.fix_tokens(pagin_config) -# data_chunk = yield event_stream.get_chunk(config=pagin_config) -# defer.returnValue(data_chunk) -# + + @defer.inlineCallbacks + def get_messages(self, user_id=None, room_id=None, pagin_config=None, + feedback=False): + """Get messages in a room. + + Args: + user_id (str): The user requesting messages. + room_id (str): The room they want messages from. + pagin_config (synapse.api.streams.PaginationConfig): The pagination + config rules to apply, if any. + feedback (bool): True to get compressed feedback with the messages + Returns: + dict: Pagination API results + """ + yield self.auth.check_joined_room(room_id, user_id) + + data_source = [EventsStreamData(self.hs, room_id=room_id, + feedback=feedback)] + event_stream = EventStream(user_id, data_source) + pagin_config = yield event_stream.fix_tokens(pagin_config) + data_chunk = yield event_stream.get_chunk(config=pagin_config) + defer.returnValue(data_chunk) + @defer.inlineCallbacks def store_room_data(self, event=None, stamp_event=True): """ Stores data for a room. |