diff --git a/templates/zerver/api/changelog.md b/templates/zerver/api/changelog.md index f3870e18d2..0eea6e7810 100644 --- a/templates/zerver/api/changelog.md +++ b/templates/zerver/api/changelog.md @@ -10,6 +10,11 @@ below features are supported. ## 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** * Added [spoilers](/help/format-your-message-using-markdown#spoilers) diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml index c473b73902..c033db8eda 100644 --- a/zerver/openapi/zulip.yaml +++ b/zerver/openapi/zulip.yaml @@ -2006,13 +2006,6 @@ paths: **Deprecated**. We plan to remove this in favor of recommending using `GET /messages` with `anchor="newest"`. 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: type: integer description: | @@ -2035,7 +2028,6 @@ paths: "date_joined": "2019-10-20T07:50:53.728864+00:00", "max_message_id": 30, "msg": "", - "pointer": -1, "result": "success", "user_id": 5, "profile_data": { diff --git a/zerver/tests/test_custom_profile_data.py b/zerver/tests/test_custom_profile_data.py index 80c87cc893..bde5afbc1b 100644 --- a/zerver/tests/test_custom_profile_data.py +++ b/zerver/tests/test_custom_profile_data.py @@ -703,7 +703,7 @@ class ListCustomProfileFieldTest(CustomProfileFieldTestCase): def test_get_custom_profile_fields_from_api_for_single_user(self) -> None: self.login('iago') 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", "avatar_version", "timezone", "delivery_email", "is_active", "is_guest", "date_joined"} diff --git a/zerver/tests/test_users.py b/zerver/tests/test_users.py index ed1fb02161..cb1a406f02 100644 --- a/zerver/tests/test_users.py +++ b/zerver/tests/test_users.py @@ -26,7 +26,6 @@ from zerver.lib.stream_topic import StreamTopicTarget from zerver.lib.test_classes import ZulipTestCase from zerver.lib.test_helpers import ( get_subscription, - most_recent_message, queries_captured, reset_emails_in_zulip_realm, simulated_empty_cache, @@ -1512,22 +1511,11 @@ class GetProfileTest(ZulipTestCase): result = self.client_post("/json/users/me/pointer", {"pointer": pointer}) self.assert_json_success(result) - def common_get_profile(self, user_id: str) -> Dict[str, Any]: - # Assumes all users are example users in realm 'zulip' + def common_get_pointer(self, user_id: str) -> Dict[str, Any]: user_profile = self.example_user(user_id) - self.send_stream_message(user_profile, "Verona", "hello") - - result = self.api_get(user_profile, "/api/v1/users/me") - - max_id = most_recent_message(user_profile).id - + result = self.api_get(user_profile, "/json/users/me/pointer") self.assert_json_success(result) json = result.json() - - self.assertIn("max_message_id", json) - self.assertIn("pointer", json) - - self.assertEqual(json["max_message_id"], max_id) return json 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 """ - json = self.common_get_profile("othello") - self.assertEqual(json["pointer"], -1) + json = self.common_get_pointer("othello") + self.assertEqual(json['pointer'], -1) def test_profile_with_pointer(self) -> None: """ @@ -1619,15 +1607,13 @@ class GetProfileTest(ZulipTestCase): id1 = 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') self.common_update_pointer(hamlet, id2) - json = self.common_get_profile("hamlet") + json = self.common_get_pointer("hamlet") self.assertEqual(json["pointer"], id2) 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 result = self.client_post("/json/users/me/pointer", {"pointer": 99999999}) diff --git a/zerver/views/users.py b/zerver/views/users.py index 9c4db54fc5..aa2efe4858 100644 --- a/zerver/views/users.py +++ b/zerver/views/users.py @@ -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['max_message_id'] = -1 - result['pointer'] = user_profile.pointer messages = Message.objects.filter(usermessage__user_profile=user_profile).order_by('-id')[:1] if messages: