mirror of https://github.com/zulip/zulip.git
alert_words: Update remove_alert_word codepath to send event on commit.
Earlier, we were immediately enqueueing event in 'do_remove_alert_words' which can lead to a situation, if any db operation is added after enqueueing event in future, where 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
ba80266b7e
commit
dc27711399
|
@ -18,6 +18,7 @@ def do_add_alert_words(user_profile: UserProfile, alert_words: Iterable[str]) ->
|
|||
notify_alert_words(user_profile, words)
|
||||
|
||||
|
||||
@transaction.atomic(savepoint=False)
|
||||
def do_remove_alert_words(user_profile: UserProfile, alert_words: Iterable[str]) -> None:
|
||||
words = remove_user_alert_words(user_profile, alert_words)
|
||||
notify_alert_words(user_profile, words)
|
||||
|
|
|
@ -72,7 +72,7 @@ def add_user_alert_words(user_profile: UserProfile, new_words: Iterable[str]) ->
|
|||
return user_alert_words(user_profile)
|
||||
|
||||
|
||||
@transaction.atomic
|
||||
@transaction.atomic(savepoint=False)
|
||||
def remove_user_alert_words(user_profile: UserProfile, delete_words: Iterable[str]) -> list[str]:
|
||||
# TODO: Ideally, this would be a bulk query, but Django doesn't have a `__iexact`.
|
||||
# We can clean this up if/when PostgreSQL has more native support for case-insensitive fields.
|
||||
|
|
Loading…
Reference in New Issue