From 8d8b6ef15604127865842e5d019a60e0dcb21050 Mon Sep 17 00:00:00 2001 From: Prakhar Pratyush Date: Mon, 2 Oct 2023 00:29:21 +0530 Subject: [PATCH] typing_indicator: Remove the "private" compatibility support. This commit removes the compatibility support for "private" being a valid value for the 'type' parameter in 'POST /typing'. "direct" and "stream" are the only valid values. --- api_docs/changelog.md | 3 +++ zerver/openapi/zulip.yaml | 6 ++++-- zerver/tests/test_typing.py | 18 ++++++++---------- zerver/views/typing.py | 8 +++----- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/api_docs/changelog.md b/api_docs/changelog.md index ba6cbfc80e..30d97b5d2e 100644 --- a/api_docs/changelog.md +++ b/api_docs/changelog.md @@ -26,6 +26,9 @@ format used by the Zulip server that they are interacting with. with `direct` in the `message_type` field for the `typing` events sent when a user starts or stops typing a message. +* [`POST /typing`](/api/set-typing-status): Stopped supporting `private` + as a valid value for the `type` parameter. + **Feature level 214** * [`PATCH /realm/user_settings_defaults`](/api/update-realm-user-settings-defaults), diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml index d810ce7b03..a56eea463e 100644 --- a/zerver/openapi/zulip.yaml +++ b/zerver/openapi/zulip.yaml @@ -16654,7 +16654,10 @@ paths: description: | Type of the message being composed. - **Changes**: In Zulip 7.0 (feature level 174), `"direct"` was added + **Changes**: In Zulip 8.0 (feature level 215), stopped supporting + `"private"` as a valid value for this parameter. + + In Zulip 7.0 (feature level 174), `"direct"` was added as the preferred way to indicate a direct message is being composed, becoming the default value for this parameter and deprecating the original `"private"`. @@ -16666,7 +16669,6 @@ paths: enum: - direct - stream - - private default: direct example: direct - name: op diff --git a/zerver/tests/test_typing.py b/zerver/tests/test_typing.py index 1cf1f51fe4..5f8fcdb574 100644 --- a/zerver/tests/test_typing.py +++ b/zerver/tests/test_typing.py @@ -133,21 +133,19 @@ class TypingValidateToArgumentsTest(ZulipTestCase): class TypingHappyPathTestPMs(ZulipTestCase): def test_valid_type_and_op_parameters(self) -> None: - recipient_type_name = ["direct", "private"] operator_type = ["start", "stop"] sender = self.example_user("hamlet") recipient_user = self.example_user("othello") - for type in recipient_type_name: - for operator in operator_type: - params = dict( - to=orjson.dumps([recipient_user.id]).decode(), - op=operator, - type=type, - ) + for operator in operator_type: + params = dict( + to=orjson.dumps([recipient_user.id]).decode(), + op=operator, + type="direct", + ) - result = self.api_post(sender, "/api/v1/typing", params) - self.assert_json_success(result) + result = self.api_post(sender, "/api/v1/typing", params) + self.assert_json_success(result) def test_start_to_single_recipient(self) -> None: sender = self.example_user("hamlet") diff --git a/zerver/views/typing.py b/zerver/views/typing.py index 87d0bf1f52..e8ff7ce947 100644 --- a/zerver/views/typing.py +++ b/zerver/views/typing.py @@ -9,9 +9,10 @@ from zerver.lib.request import REQ, has_request_variables from zerver.lib.response import json_success from zerver.lib.streams import access_stream_by_id, access_stream_for_send_message from zerver.lib.validator import check_int, check_list, check_string_in -from zerver.models import Message, UserProfile +from zerver.models import UserProfile VALID_OPERATOR_TYPES = ["start", "stop"] +VALID_RECIPIENT_TYPES = ["direct", "stream"] @has_request_variables @@ -19,7 +20,7 @@ def send_notification_backend( request: HttpRequest, user_profile: UserProfile, req_type: str = REQ( - "type", str_validator=check_string_in(Message.API_RECIPIENT_TYPES), default="direct" + "type", str_validator=check_string_in(VALID_RECIPIENT_TYPES), default="direct" ), operator: str = REQ("op", str_validator=check_string_in(VALID_OPERATOR_TYPES)), notification_to: List[int] = REQ("to", json_validator=check_list(check_int)), @@ -31,9 +32,6 @@ def send_notification_backend( raise JsonableError(_("Empty 'to' list")) recipient_type_name = req_type - if recipient_type_name == "private": - recipient_type_name = "direct" - if recipient_type_name == "stream": if to_length > 1: raise JsonableError(_("Cannot send to multiple streams"))