diff --git a/zerver/lib/message.py b/zerver/lib/message.py index e062642436..60d7d1367c 100644 --- a/zerver/lib/message.py +++ b/zerver/lib/message.py @@ -1010,6 +1010,9 @@ def extract_unread_data_from_um_rows( if topic_mute_checker(recipient_id, topic): return True + # Messages sent by muted users are never unread, so we don't + # need any logic related to muted users here. + return False huddle_cache: Dict[int, str] = {} diff --git a/zerver/views/message_fetch.py b/zerver/views/message_fetch.py index f50f446591..566c175588 100644 --- a/zerver/views/message_fetch.py +++ b/zerver/views/message_fetch.py @@ -736,6 +736,9 @@ def exclude_muting_conditions( except Stream.DoesNotExist: pass + # Stream-level muting only applies when looking at views that + # include multiple streams, since we do want users to be able to + # browser messages within a muted stream. if stream_id is None: rows = Subscription.objects.filter( user_profile=user_profile, @@ -751,6 +754,15 @@ def exclude_muting_conditions( conditions = exclude_topic_mutes(conditions, user_profile, stream_id) + # Muted user logic for hiding messages is implemented entirely + # client-side. This is by design, as it allows UI to hint that + # muted messages exist where their absence might make conversation + # difficult to understand. As a result, we do not need to consider + # muted users in this server-side logic for returning messages to + # clients. (We could in theory exclude PMs from muted users, but + # they're likely to be sufficiently rare to not be worth extra + # logic/testing here). + return conditions