From d2074fc10c8bb9415eac23fab70735df29eba994 Mon Sep 17 00:00:00 2001 From: Gaurav Pandey Date: Sat, 12 Jun 2021 20:05:17 +0530 Subject: [PATCH] events: Remove `sender_id` from `delete_message` event. Remove `sender_id` as part of responses from `/events` api for `delete_message` event when `message_type` is `private`. --- templates/zerver/api/changelog.md | 6 ++++++ version.py | 2 +- zerver/lib/actions.py | 3 --- zerver/lib/event_schema.py | 3 +-- zerver/openapi/zulip.yaml | 11 ++++------- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/templates/zerver/api/changelog.md b/templates/zerver/api/changelog.md index 69ece02dfb..bdb12b59b0 100644 --- a/templates/zerver/api/changelog.md +++ b/templates/zerver/api/changelog.md @@ -11,6 +11,12 @@ below features are supported. ## Changes in Zulip 5.0 +**Feature level 77** + +* [`GET /events`](/api/get-events): Removed `recipient_id` and + `sender_id` field in responses of `delete_message` event when + `message_type` is `private`. + **Feature level 76** * [`POST /fetch_api_key`](/api/fetch_api_key), [`POST diff --git a/version.py b/version.py index 377c2e4809..6630794110 100644 --- a/version.py +++ b/version.py @@ -33,7 +33,7 @@ DESKTOP_WARNING_VERSION = "5.4.3" # Changes should be accompanied by documentation explaining what the # new level means in templates/zerver/api/changelog.md, as well as # "**Changes**" entries in the endpoint's documentation in `zulip.yaml`. -API_FEATURE_LEVEL = 76 +API_FEATURE_LEVEL = 77 # Bump the minor PROVISION_VERSION to indicate that folks should provision # only when going from an old version of the code to a newer version. Bump diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index 645612c1e8..6362a038f1 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.py @@ -5896,7 +5896,6 @@ class DeleteMessagesEvent(TypedDict, total=False): type: str message_ids: List[int] message_type: str - sender_id: int topic: str stream_id: int @@ -6323,8 +6322,6 @@ def do_delete_messages(realm: Realm, messages: Iterable[Message]) -> None: message_type = "private" ums = UserMessage.objects.filter(message_id__in=message_ids) users_to_notify = [um.user_profile_id for um in ums] - # TODO: We should plan to remove `sender_id` here. - event["sender_id"] = sample_message.sender_id archiving_chunk_size = retention.MESSAGE_BATCH_SIZE if message_type == "stream": diff --git a/zerver/lib/event_schema.py b/zerver/lib/event_schema.py index 9b01828443..d47afd05ce 100644 --- a/zerver/lib/event_schema.py +++ b/zerver/lib/event_schema.py @@ -230,7 +230,6 @@ delete_message_event = event_dict_type( ("message_ids", ListType(int)), ("stream_id", int), ("topic", str), - ("sender_id", int), ], ) _check_delete_message = make_checker(delete_message_event) @@ -252,7 +251,7 @@ def check_delete_message( if message_type == "stream": keys |= {"stream_id", "topic"} elif message_type == "private": - keys |= {"sender_id"} + pass else: raise AssertionError("unexpected message_type") diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml index adb2e77f4e..ce6a9bd56a 100644 --- a/zerver/openapi/zulip.yaml +++ b/zerver/openapi/zulip.yaml @@ -1660,6 +1660,10 @@ paths: description: | Event sent when a message has been deleted. Sent to all users who received the message. + + **Changes**: Before Zulip 5.0 (feature level 77), events + for private messages contained additional `sender_id` and + `recipient_id` fields. properties: id: $ref: "#/components/schemas/EventIdSchema" @@ -1693,12 +1697,6 @@ paths: enum: - private - stream - sender_id: - type: integer - description: | - Only present for private messages. - - The ID of the user who sent the private message. stream_id: type: integer description: | @@ -1714,7 +1712,6 @@ paths: example: { "type": "delete_message", - "sender_id": 8, "message_type": "private", "message_id": 37, "id": 0,