mirror of https://github.com/zulip/zulip.git
muting: Add a flag to allow user duplicate mutes to silently succeed.
This commit is contained in:
parent
2762121162
commit
781107308d
|
@ -8031,10 +8031,18 @@ def do_mute_topic(
|
|||
stream: Stream,
|
||||
topic: str,
|
||||
date_muted: Optional[datetime.datetime] = None,
|
||||
ignore_duplicate: bool = False,
|
||||
) -> None:
|
||||
if date_muted is None:
|
||||
date_muted = timezone_now()
|
||||
add_topic_mute(user_profile, stream.id, stream.recipient_id, topic, date_muted)
|
||||
add_topic_mute(
|
||||
user_profile,
|
||||
stream.id,
|
||||
stream.recipient_id,
|
||||
topic,
|
||||
date_muted,
|
||||
ignore_duplicate=ignore_duplicate,
|
||||
)
|
||||
event = dict(type="muted_topics", muted_topics=get_topic_mutes(user_profile))
|
||||
send_event(user_profile.realm, event, [user_profile.id])
|
||||
|
||||
|
|
|
@ -65,16 +65,22 @@ def add_topic_mute(
|
|||
recipient_id: int,
|
||||
topic_name: str,
|
||||
date_muted: Optional[datetime.datetime] = None,
|
||||
ignore_duplicate: bool = False,
|
||||
) -> None:
|
||||
if date_muted is None:
|
||||
date_muted = timezone_now()
|
||||
UserTopic.objects.create(
|
||||
user_profile=user_profile,
|
||||
stream_id=stream_id,
|
||||
recipient_id=recipient_id,
|
||||
topic_name=topic_name,
|
||||
last_updated=date_muted,
|
||||
visibility_policy=UserTopic.MUTED,
|
||||
UserTopic.objects.bulk_create(
|
||||
[
|
||||
UserTopic(
|
||||
user_profile=user_profile,
|
||||
stream_id=stream_id,
|
||||
recipient_id=recipient_id,
|
||||
topic_name=topic_name,
|
||||
last_updated=date_muted,
|
||||
visibility_policy=UserTopic.MUTED,
|
||||
),
|
||||
],
|
||||
ignore_conflicts=ignore_duplicate,
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue