mute user: Mark as read old messages immediately.

When a user is muted, in the same request,
we mark any existing unreads from that user
as read.

This is done for all types of messages
(PM/huddle/stream) and regardless of whether
the user was mentioned in them.

This will not break the unread count logic
of the web frontend, because that algorithm
decides which messages to mark as read based
only on the pointer location and the whitespace
at the bottom, not on what messages have already
been marked as read.
This commit is contained in:
Abhijeet Prasad Bodas
2021-03-27 18:22:30 +05:30
committed by Tim Abbott
parent 2f56f8d0ed
commit 8b098b95bb
3 changed files with 87 additions and 2 deletions

View File

@@ -1011,8 +1011,11 @@ class NormalActionsTest(BaseAction):
def test_muted_users_events(self) -> None:
muted_user = self.example_user("othello")
events = self.verify_action(lambda: do_mute_user(self.user_profile, muted_user))
check_muted_users("events[0]", events[0])
events = self.verify_action(
lambda: do_mute_user(self.user_profile, muted_user), num_events=2
)
check_update_message_flags_add("events[0]", events[0])
check_muted_users("events[1]", events[1])
mute_object = get_mute_object(self.user_profile, muted_user)
assert mute_object is not None