From 963fe566d72278e9e6e87127522e49340673e68a Mon Sep 17 00:00:00 2001 From: Aman Agrawal Date: Fri, 21 Apr 2023 10:48:29 +0000 Subject: [PATCH] scheduled_messages: Use scheduled_message_id instead of message_id. Using `message_id` can be confusing for API users since it can be mistaken for the ID of the message that will be sent. --- web/src/scheduled_messages.js | 2 +- web/templates/scheduled_message.hbs | 2 +- zerver/openapi/zulip.yaml | 9 +++++---- zerver/tests/test_scheduled_messages.py | 4 +++- zerver/views/scheduled_messages.py | 4 ++-- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/web/src/scheduled_messages.js b/web/src/scheduled_messages.js index fcc2170e22..f4ba532bed 100644 --- a/web/src/scheduled_messages.js +++ b/web/src/scheduled_messages.js @@ -19,7 +19,7 @@ export function override_scheduled_messages_data(data) { export function edit_scheduled_message(scheduled_msg_id) { const scheduled_msg = scheduled_messages_data.find( - (msg) => msg.message_id === scheduled_msg_id, + (msg) => msg.scheduled_message_id === scheduled_msg_id, ); let compose_args; diff --git a/web/templates/scheduled_message.hbs b/web/templates/scheduled_message.hbs index cbff66b79e..57769b35e8 100644 --- a/web/templates/scheduled_message.hbs +++ b/web/templates/scheduled_message.hbs @@ -1,5 +1,5 @@ {{#each scheduled_messages_data}} -
+
{{#if is_stream}}
diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml index 27b20a84c8..f404169741 100644 --- a/zerver/openapi/zulip.yaml +++ b/zerver/openapi/zulip.yaml @@ -5032,7 +5032,7 @@ paths: "scheduled_messages": [ { - "message_id": 27, + "scheduled_message_id": 27, "to": [14], "type": "stream", "content": "Hi", @@ -17342,11 +17342,12 @@ components: description: | A dictionary for representing a scheduled message. properties: - message_id: + scheduled_message_id: type: integer description: | The unique ID of the scheduled message. It can be used to modify and - delete the scheduled message. + delete the scheduled message. This ID is different than the ID of the + message that will actually be sent. type: type: string description: | @@ -17388,7 +17389,7 @@ components: example: 1595479019 additionalProperties: false required: - - message_id + - scheduled_message_id - type - to - topic diff --git a/zerver/tests/test_scheduled_messages.py b/zerver/tests/test_scheduled_messages.py index 1504b0d716..7271826ed1 100644 --- a/zerver/tests/test_scheduled_messages.py +++ b/zerver/tests/test_scheduled_messages.py @@ -217,7 +217,9 @@ class ScheduledMessageTest(ZulipTestCase): scheduled_messages = orjson.loads(result.content)["scheduled_messages"] self.assert_length(scheduled_messages, 1) - self.assertEqual(scheduled_messages[0]["message_id"], self.last_scheduled_message().id) + self.assertEqual( + scheduled_messages[0]["scheduled_message_id"], self.last_scheduled_message().id + ) self.assertEqual(scheduled_messages[0]["content"], content) self.assertEqual(scheduled_messages[0]["to"], [self.get_stream_id("Verona")]) self.assertEqual(scheduled_messages[0]["type"], "stream") diff --git a/zerver/views/scheduled_messages.py b/zerver/views/scheduled_messages.py index 247e586a55..83fb6588a0 100644 --- a/zerver/views/scheduled_messages.py +++ b/zerver/views/scheduled_messages.py @@ -9,7 +9,7 @@ from zerver.models import ScheduledMessage, UserProfile, get_recipient_ids class ScheduledMessageDict(TypedDict): - message_id: int + scheduled_message_id: int to: List[int] type: str content: str @@ -31,7 +31,7 @@ def fetch_scheduled_messages(request: HttpRequest, user_profile: UserProfile) -> ) msg_to_dict: ScheduledMessageDict = { - "message_id": scheduled_message.id, + "scheduled_message_id": scheduled_message.id, "to": recipient, "type": recipient_type_str, "content": scheduled_message.content,