mirror of https://github.com/zulip/zulip.git
drafts: Update do_edit_draft to send event on commit.
Earlier, we were using 'send_event' in 'do_edit_draft' which can lead to a situation, if any db operation is added after the 'send_event' in future, where we enqueue events but the action function fails at a later stage. Events should not be sent until we know we're not rolling back. Fixes part of #30489.
This commit is contained in:
parent
ed7c399644
commit
096647fbd5
|
@ -142,10 +142,12 @@ def do_edit_draft(draft_id: int, draft: DraftData, user_profile: UserProfile) ->
|
|||
draft_object.topic = valid_draft_dict["topic"]
|
||||
draft_object.recipient_id = valid_draft_dict["recipient_id"]
|
||||
draft_object.last_edit_time = valid_draft_dict["last_edit_time"]
|
||||
draft_object.save()
|
||||
|
||||
event = {"type": "drafts", "op": "update", "draft": draft_object.to_dict()}
|
||||
send_event(user_profile.realm, event, [user_profile.id])
|
||||
with transaction.atomic(durable=True):
|
||||
draft_object.save()
|
||||
|
||||
event = {"type": "drafts", "op": "update", "draft": draft_object.to_dict()}
|
||||
send_event_on_commit(user_profile.realm, event, [user_profile.id])
|
||||
|
||||
|
||||
def do_delete_draft(draft_id: int, user_profile: UserProfile) -> None:
|
||||
|
|
Loading…
Reference in New Issue