diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index facca8ec1b..d30efc281e 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.py @@ -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]) diff --git a/zerver/tests/test_event_queue.py b/zerver/tests/test_event_queue.py index c295598811..3c47909a4b 100644 --- a/zerver/tests/test_event_queue.py +++ b/zerver/tests/test_event_queue.py @@ -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: diff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.py index 12c9f6cef6..4664f1deaf 100644 --- a/zerver/tests/test_events.py +++ b/zerver/tests/test_events.py @@ -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]) diff --git a/zerver/views/muting.py b/zerver/views/muting.py index c4f46c5aee..8887cd86da 100644 --- a/zerver/views/muting.py +++ b/zerver/views/muting.py @@ -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,