Fix edge case on get_messages when reverse=True (#4455)

Closes #4453.
This commit is contained in:
kristal 2024-09-05 18:00:22 +03:00 committed by GitHub
parent aec957d62d
commit b01d3d7a2f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -221,7 +221,7 @@ class _MessagesIter(RequestIter):
# #
# We also assume the API will always return, at least, one message if # We also assume the API will always return, at least, one message if
# there is more to fetch. # there is more to fetch.
if not r.messages or r.messages[0].id <= self.request.limit: if not r.messages or (not self.reverse and r.messages[0].id <= self.request.limit):
return True return True
# Get the last message that's not empty (in some rare cases # Get the last message that's not empty (in some rare cases