From ea2fcaea62dbba0184b41631ae7267564cae7b93 Mon Sep 17 00:00:00 2001 From: Matthias Schmitz Date: Fri, 5 Oct 2018 11:49:26 +0200 Subject: [PATCH] Fix missing update of start_token while backfill prev messages The function backfill_previous_messages() updates the room's event list (room.events) using the api function "client.api.get_room_messages". The latter function takes a start token as parameter to know from where in the history of events to start. backfill_previous_messages() handes over self.prev_batch as start token but never updates it. So repeated calls to backfill_previous_messages() always return the same chunk of events from the room's event history. This commit fixes this wrong behavior by updating self.prev_batch on every function call. Signed-off-by: Matthias Schmitz --- matrix_client/room.py | 1 + 1 file changed, 1 insertion(+) diff --git a/matrix_client/room.py b/matrix_client/room.py index 488f335b..0f87b01f 100644 --- a/matrix_client/room.py +++ b/matrix_client/room.py @@ -507,6 +507,7 @@ def backfill_previous_messages(self, reverse=False, limit=10): res = self.client.api.get_room_messages(self.room_id, self.prev_batch, direction="b", limit=limit) events = res["chunk"] + self.prev_batch = res["end"] if not reverse: events = reversed(events) for event in events: