From d1dfab5b70e5bcac6a35aa208add068478e4a197 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Thu, 4 May 2023 15:54:17 -0700 Subject: [PATCH] scheduled_messages: Live update #scheduled view after sending. We apparently had neglected to send the actual event to clients that the message was successfully sent. --- zerver/actions/scheduled_messages.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/zerver/actions/scheduled_messages.py b/zerver/actions/scheduled_messages.py index 1cd0b22d91..180a46e1b9 100644 --- a/zerver/actions/scheduled_messages.py +++ b/zerver/actions/scheduled_messages.py @@ -164,11 +164,7 @@ def edit_scheduled_message( return scheduled_message_id -def delete_scheduled_message(user_profile: UserProfile, scheduled_message_id: int) -> None: - scheduled_message_object = access_scheduled_message(user_profile, scheduled_message_id) - scheduled_message_id = scheduled_message_object.id - scheduled_message_object.delete() - +def notify_remove_scheduled_message(user_profile: UserProfile, scheduled_message_id: int) -> None: event = { "type": "scheduled_messages", "op": "remove", @@ -177,6 +173,14 @@ def delete_scheduled_message(user_profile: UserProfile, scheduled_message_id: in send_event(user_profile.realm, event, [user_profile.id]) +def delete_scheduled_message(user_profile: UserProfile, scheduled_message_id: int) -> None: + scheduled_message_object = access_scheduled_message(user_profile, scheduled_message_id) + scheduled_message_id = scheduled_message_object.id + scheduled_message_object.delete() + + notify_remove_scheduled_message(user_profile, scheduled_message_id) + + def construct_send_request(scheduled_message: ScheduledMessage) -> SendMessageRequest: message = Message() original_sender = scheduled_message.sender @@ -205,3 +209,4 @@ def send_scheduled_message(scheduled_message: ScheduledMessage) -> None: do_send_messages([message_send_request]) scheduled_message.delivered = True scheduled_message.save(update_fields=["delivered"]) + notify_remove_scheduled_message(scheduled_message.sender, scheduled_message.id)