Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
alert_words: Update add_alert_words codepath to send event on commit.
Prakhar Pratyushba80266b7e8f
diff --git a/zerver/actions/alert_words.py b/zerver/actions/alert_words.pyindex a9202873dce..f21b2737469 100644--- a/zerver/actions/alert_words.py+++ b/zerver/actions/alert_words.py@@ -1,15 +1,18 @@from collections.abc import Iterable, Sequence+from django.db import transaction+from zerver.lib.alert_words import add_user_alert_words, remove_user_alert_wordsfrom zerver.models import UserProfile-from zerver.tornado.django_api import send_event+from zerver.tornado.django_api import send_event_on_commitdef notify_alert_words(user_profile: UserProfile, words: Sequence[str]) -> None:event = dict(type="alert_words", alert_words=words)- send_event(user_profile.realm, event, [user_profile.id])+ send_event_on_commit(user_profile.realm, event, [user_profile.id])[email protected](savepoint=False)def do_add_alert_words(user_profile: UserProfile, alert_words: Iterable[str]) -> None:words = add_user_alert_words(user_profile, alert_words)notify_alert_words(user_profile, words)diff --git a/zerver/lib/alert_words.py b/zerver/lib/alert_words.pyindex 5e51928d544..a5d686c654f 100644--- a/zerver/lib/alert_words.py+++ b/zerver/lib/alert_words.py@@ -50,7 +50,7 @@ def user_alert_words(user_profile: UserProfile) -> list[str]:return list(AlertWord.objects.filter(user_profile=user_profile).values_list("word", flat=True))[email protected](savepoint=False)def add_user_alert_words(user_profile: UserProfile, new_words: Iterable[str]) -> list[str]:existing_words_lower = {word.lower() for word in user_alert_words(user_profile)}