pointer: Remove pointer from GET /users/me.

This cleans up a bit of mess in the Zulip API.
This commit is contained in:
Tim Abbott 2020-06-18 00:18:29 -07:00 committed by Tim Abbott
parent b77da6b834
commit f8ea5f3769
5 changed files with 12 additions and 30 deletions

View File

@ -10,6 +10,11 @@ below features are supported.
## Changes in Zulip 2.2 ## Changes in Zulip 2.2
**Feature level 16**
* [`GET /users/me`]: Removed `pointer` from the response, as the
"pointer" concept is being removed in Zulip.
**Feature level 15** **Feature level 15**
* Added [spoilers](/help/format-your-message-using-markdown#spoilers) * Added [spoilers](/help/format-your-message-using-markdown#spoilers)

View File

@ -2006,13 +2006,6 @@ paths:
**Deprecated**. We plan to remove this in favor of recommending **Deprecated**. We plan to remove this in favor of recommending
using `GET /messages` with `anchor="newest"`. using `GET /messages` with `anchor="newest"`.
example: 30 example: 30
pointer:
type: integer
description: |
The integer ID of the message that the pointer is currently on.
**Deprecated**. We plan to remove the `pointer` as a concept in Zulip.
example: -1
user_id: user_id:
type: integer type: integer
description: | description: |
@ -2035,7 +2028,6 @@ paths:
"date_joined": "2019-10-20T07:50:53.728864+00:00", "date_joined": "2019-10-20T07:50:53.728864+00:00",
"max_message_id": 30, "max_message_id": 30,
"msg": "", "msg": "",
"pointer": -1,
"result": "success", "result": "success",
"user_id": 5, "user_id": 5,
"profile_data": { "profile_data": {

View File

@ -703,7 +703,7 @@ class ListCustomProfileFieldTest(CustomProfileFieldTestCase):
def test_get_custom_profile_fields_from_api_for_single_user(self) -> None: def test_get_custom_profile_fields_from_api_for_single_user(self) -> None:
self.login('iago') self.login('iago')
expected_keys = { expected_keys = {
"result", "msg", "pointer", "max_message_id", "user_id", "avatar_url", "result", "msg", "max_message_id", "user_id", "avatar_url",
"full_name", "email", "is_bot", "is_admin", "is_owner", "profile_data", "full_name", "email", "is_bot", "is_admin", "is_owner", "profile_data",
"avatar_version", "timezone", "delivery_email", "is_active", "is_guest", "avatar_version", "timezone", "delivery_email", "is_active", "is_guest",
"date_joined"} "date_joined"}

View File

@ -26,7 +26,6 @@ from zerver.lib.stream_topic import StreamTopicTarget
from zerver.lib.test_classes import ZulipTestCase from zerver.lib.test_classes import ZulipTestCase
from zerver.lib.test_helpers import ( from zerver.lib.test_helpers import (
get_subscription, get_subscription,
most_recent_message,
queries_captured, queries_captured,
reset_emails_in_zulip_realm, reset_emails_in_zulip_realm,
simulated_empty_cache, simulated_empty_cache,
@ -1512,22 +1511,11 @@ class GetProfileTest(ZulipTestCase):
result = self.client_post("/json/users/me/pointer", {"pointer": pointer}) result = self.client_post("/json/users/me/pointer", {"pointer": pointer})
self.assert_json_success(result) self.assert_json_success(result)
def common_get_profile(self, user_id: str) -> Dict[str, Any]: def common_get_pointer(self, user_id: str) -> Dict[str, Any]:
# Assumes all users are example users in realm 'zulip'
user_profile = self.example_user(user_id) user_profile = self.example_user(user_id)
self.send_stream_message(user_profile, "Verona", "hello") result = self.api_get(user_profile, "/json/users/me/pointer")
result = self.api_get(user_profile, "/api/v1/users/me")
max_id = most_recent_message(user_profile).id
self.assert_json_success(result) self.assert_json_success(result)
json = result.json() json = result.json()
self.assertIn("max_message_id", json)
self.assertIn("pointer", json)
self.assertEqual(json["max_message_id"], max_id)
return json return json
def test_get_pointer(self) -> None: def test_get_pointer(self) -> None:
@ -1608,8 +1596,8 @@ class GetProfileTest(ZulipTestCase):
""" """
Ensure GET /users/me returns a max message id and returns successfully Ensure GET /users/me returns a max message id and returns successfully
""" """
json = self.common_get_profile("othello") json = self.common_get_pointer("othello")
self.assertEqual(json["pointer"], -1) self.assertEqual(json['pointer'], -1)
def test_profile_with_pointer(self) -> None: def test_profile_with_pointer(self) -> None:
""" """
@ -1619,15 +1607,13 @@ class GetProfileTest(ZulipTestCase):
id1 = self.send_stream_message(self.example_user("othello"), "Verona") id1 = self.send_stream_message(self.example_user("othello"), "Verona")
id2 = self.send_stream_message(self.example_user("othello"), "Verona") id2 = self.send_stream_message(self.example_user("othello"), "Verona")
json = self.common_get_profile("hamlet")
hamlet = self.example_user('hamlet') hamlet = self.example_user('hamlet')
self.common_update_pointer(hamlet, id2) self.common_update_pointer(hamlet, id2)
json = self.common_get_profile("hamlet") json = self.common_get_pointer("hamlet")
self.assertEqual(json["pointer"], id2) self.assertEqual(json["pointer"], id2)
self.common_update_pointer(hamlet, id1) self.common_update_pointer(hamlet, id1)
json = self.common_get_profile("hamlet") json = self.common_get_pointer("hamlet")
self.assertEqual(json["pointer"], id2) # pointer does not move backwards self.assertEqual(json["pointer"], id2) # pointer does not move backwards
result = self.client_post("/json/users/me/pointer", {"pointer": 99999999}) result = self.client_post("/json/users/me/pointer", {"pointer": 99999999})

View File

@ -505,7 +505,6 @@ def get_profile_backend(request: HttpRequest, user_profile: UserProfile) -> Http
result: Dict[str, Any] = raw_user_data[user_profile.id] result: Dict[str, Any] = raw_user_data[user_profile.id]
result['max_message_id'] = -1 result['max_message_id'] = -1
result['pointer'] = user_profile.pointer
messages = Message.objects.filter(usermessage__user_profile=user_profile).order_by('-id')[:1] messages = Message.objects.filter(usermessage__user_profile=user_profile).order_by('-id')[:1]
if messages: if messages: