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.
This commit is contained in:
Tim Abbott 2023-05-04 15:54:17 -07:00
parent c8f3443fb6
commit d1dfab5b70
1 changed files with 10 additions and 5 deletions

View File

@ -164,11 +164,7 @@ def edit_scheduled_message(
return scheduled_message_id return scheduled_message_id
def delete_scheduled_message(user_profile: UserProfile, scheduled_message_id: int) -> None: def notify_remove_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()
event = { event = {
"type": "scheduled_messages", "type": "scheduled_messages",
"op": "remove", "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]) 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: def construct_send_request(scheduled_message: ScheduledMessage) -> SendMessageRequest:
message = Message() message = Message()
original_sender = scheduled_message.sender original_sender = scheduled_message.sender
@ -205,3 +209,4 @@ def send_scheduled_message(scheduled_message: ScheduledMessage) -> None:
do_send_messages([message_send_request]) do_send_messages([message_send_request])
scheduled_message.delivered = True scheduled_message.delivered = True
scheduled_message.save(update_fields=["delivered"]) scheduled_message.save(update_fields=["delivered"])
notify_remove_scheduled_message(scheduled_message.sender, scheduled_message.id)