mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-12-25 10:29:22 -05:00
Don't return end
from /messages
if there are no more events (#12903)
Signed-off-by: Jacek Kusnierz <jacek.kusnierz@tum.de>
This commit is contained in:
parent
cd9fc058de
commit
c4f548e05d
1
changelog.d/12903.bugfix
Normal file
1
changelog.d/12903.bugfix
Normal file
@ -0,0 +1 @@
|
||||
Fix a long-standing bug which caused the `/messages` endpoint to return an incorrect `end` attribute when there were no more events. Contributed by @Vetchu.
|
@ -515,7 +515,16 @@ class PaginationHandler:
|
||||
|
||||
next_token = from_token.copy_and_replace(StreamKeyType.ROOM, next_key)
|
||||
|
||||
if events:
|
||||
# if no events are returned from pagination, that implies
|
||||
# we have reached the end of the available events.
|
||||
# In that case we do not return end, to tell the client
|
||||
# there is no need for further queries.
|
||||
if not events:
|
||||
return {
|
||||
"chunk": [],
|
||||
"start": await from_token.to_string(self.store),
|
||||
}
|
||||
|
||||
if event_filter:
|
||||
events = await event_filter.filter(events)
|
||||
|
||||
@ -523,6 +532,8 @@ class PaginationHandler:
|
||||
self.storage, user_id, events, is_peeking=(member_event_id is None)
|
||||
)
|
||||
|
||||
# if after the filter applied there are no more events
|
||||
# return immediately - but there might be more in next_token batch
|
||||
if not events:
|
||||
return {
|
||||
"chunk": [],
|
||||
|
Loading…
Reference in New Issue
Block a user