mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 17:07:07 +00:00
refactor: Remove recipient arg for do_mute_topic.
This commit is contained in:
@@ -5461,11 +5461,15 @@ def do_remove_alert_words(user_profile: UserProfile, alert_words: Iterable[str])
|
||||
words = remove_user_alert_words(user_profile, alert_words)
|
||||
notify_alert_words(user_profile, words)
|
||||
|
||||
def do_mute_topic(user_profile: UserProfile, stream: Stream, recipient: Recipient, topic: str,
|
||||
date_muted: Optional[datetime.datetime]=None) -> None:
|
||||
def do_mute_topic(
|
||||
user_profile: UserProfile,
|
||||
stream: Stream,
|
||||
topic: str,
|
||||
date_muted: Optional[datetime.datetime]=None
|
||||
) -> None:
|
||||
if date_muted is None:
|
||||
date_muted = timezone_now()
|
||||
add_topic_mute(user_profile, stream.id, recipient.id, topic, date_muted)
|
||||
add_topic_mute(user_profile, stream.id, stream.recipient_id, topic, date_muted)
|
||||
event = dict(type="muted_topics", muted_topics=get_topic_mutes(user_profile))
|
||||
send_event(user_profile.realm, event, [user_profile.id])
|
||||
|
||||
|
||||
@@ -441,7 +441,7 @@ class MissedMessageNotificationsTest(ZulipTestCase):
|
||||
'email_notifications': False})
|
||||
|
||||
self.assertTrue(client_descriptor.event_queue.empty())
|
||||
do_mute_topic(user_profile, stream, sub.recipient, "mutingtest")
|
||||
do_mute_topic(user_profile, stream, "mutingtest")
|
||||
msg_id = self.send_stream_message(self.example_user("iago"), "Denmark",
|
||||
content="what's up everyone?", topic_name="mutingtest")
|
||||
with mock.patch("zerver.tornado.event_queue.maybe_enqueue_notifications") as mock_enqueue:
|
||||
|
||||
@@ -954,12 +954,10 @@ class NormalActionsTest(BaseAction):
|
||||
|
||||
def test_muted_topics_events(self) -> None:
|
||||
stream = get_stream('Denmark', self.user_profile.realm)
|
||||
recipient = stream.recipient
|
||||
events = self.verify_action(
|
||||
lambda: do_mute_topic(
|
||||
self.user_profile,
|
||||
stream,
|
||||
recipient,
|
||||
"topic"))
|
||||
check_muted_topics('events[0]', events[0])
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ def mute_topic(user_profile: UserProfile,
|
||||
if topic_is_muted(user_profile, stream.id, topic_name):
|
||||
return json_error(_("Topic already muted"))
|
||||
|
||||
do_mute_topic(user_profile, stream, recipient, topic_name, date_muted)
|
||||
do_mute_topic(user_profile, stream, topic_name, date_muted)
|
||||
return json_success()
|
||||
|
||||
def unmute_topic(user_profile: UserProfile,
|
||||
|
||||
Reference in New Issue
Block a user