mirror of https://github.com/zulip/zulip.git
muting: Fix a race in topic unmuting.
Rather than check if the topic exists and then try to delete it, just try to delete it, and catch the lack of matching rows.
This commit is contained in:
parent
6bc5849ea8
commit
915c2b2fd9
|
@ -230,6 +230,7 @@ from zerver.models import (
|
||||||
UserPresence,
|
UserPresence,
|
||||||
UserProfile,
|
UserProfile,
|
||||||
UserStatus,
|
UserStatus,
|
||||||
|
UserTopic,
|
||||||
active_non_guest_user_ids,
|
active_non_guest_user_ids,
|
||||||
active_user_ids,
|
active_user_ids,
|
||||||
custom_profile_fields_for_realm,
|
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:
|
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))
|
event = dict(type="muted_topics", muted_topics=get_topic_mutes(user_profile))
|
||||||
send_event(user_profile.realm, event, [user_profile.id])
|
send_event(user_profile.realm, event, [user_profile.id])
|
||||||
|
|
||||||
|
|
|
@ -54,9 +54,6 @@ def unmute_topic(
|
||||||
assert stream_id is not None
|
assert stream_id is not None
|
||||||
stream = access_stream_for_unmute_topic_by_id(user_profile, stream_id, error)
|
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)
|
do_unmute_topic(user_profile, stream, topic_name)
|
||||||
return json_success()
|
return json_success()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue