narrow: Fix server handling of other larger anchor values.

This fixes a bug where that clients using the legacy approach of a
"very large anchor" value with the intent to only get the most recent
messages would only get found_newest=True if they used the specific
value LARGER_THAN_MAX_MESSAGE_ID.  Now any value at least that large
will work.

In upcoming commits, we plan to replace this with passing the string
"last", but it seems worth removing the buggy "special value" behavior
while we're touching this code.
This commit is contained in:
Tim Abbott 2020-01-27 21:31:29 -08:00
parent c0712431df
commit e2810d7549
2 changed files with 2 additions and 3 deletions

View File

@ -2163,7 +2163,6 @@ class GetOldMessagesTest(ZulipTestCase):
self.assertEqual(data['found_newest'], True)
self.assertEqual(data['history_limited'], False)
# BUG: The LARGER_THAN_MAX_MESSAGE_ID value is important to the found_newest value.
with first_visible_id_as(0):
data = self.get_messages_response(anchor=LARGER_THAN_MAX_MESSAGE_ID + 1,
num_before=5, num_after=0)
@ -2172,7 +2171,7 @@ class GetOldMessagesTest(ZulipTestCase):
self.assert_length(messages, 5)
self.assertEqual(data['found_anchor'], False)
self.assertEqual(data['found_oldest'], False)
self.assertEqual(data['found_newest'], False)
self.assertEqual(data['found_newest'], True)
self.assertEqual(data['history_limited'], False)
with first_visible_id_as(0):

View File

@ -842,7 +842,7 @@ def get_messages_backend(request: HttpRequest, user_profile: UserProfile,
# Set value that will be used to short circuit the after_query
# altogether and avoid needless conditions in the before_query.
anchored_to_right = (anchor == LARGER_THAN_MAX_MESSAGE_ID)
anchored_to_right = (anchor >= LARGER_THAN_MAX_MESSAGE_ID)
if anchored_to_right:
num_after = 0