Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

muting: Fix a race in topic unmuting.

Alex Vandiver915c2b2fd9c0
diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py
index c08d48d464b..9639d4e8498 100644
--- a/zerver/lib/actions.py
+++ b/zerver/lib/actions.py
@@ -230,6 +230,7 @@ from zerver.models import (
UserPresence,
UserProfile,
UserStatus,
+ UserTopic,
active_non_guest_user_ids,
active_user_ids,
custom_profile_fields_for_realm,
@@ -7781,7 +7782,10 @@ def do_mute_topic(
def do_unmute_topic(user_profile: UserProfile, stream: Stream, topic: str) -> None:
- remove_topic_mute(user_profile, stream.id, topic)
+ try:
+ remove_topic_mute(user_profile, stream.id, topic)
+ except UserTopic.DoesNotExist:
+ raise JsonableError(_("Topic is not muted"))
event = dict(type="muted_topics", muted_topics=get_topic_mutes(user_profile))
send_event(user_profile.realm, event, [user_profile.id])
diff --git a/zerver/views/muting.py b/zerver/views/muting.py
index 582c4dd3164..f5fc4ab9f3f 100644
--- a/zerver/views/muting.py
+++ b/zerver/views/muting.py
@@ -54,9 +54,6 @@ def unmute_topic(
assert stream_id is not None
stream = access_stream_for_unmute_topic_by_id(user_profile, stream_id, error)
- if not topic_is_muted(user_profile, stream.id, topic_name):
- raise JsonableError(error)
-
do_unmute_topic(user_profile, stream, topic_name)
return json_success()