unread_msgs: Fix all unreads in muted stream being treated as muted.

Earlier, 'is_row_muted' returned 'true' if the message was in
a muted stream or muted topic.

If the message is in an unmuted or followed topic in a muted
stream, such topics should be treated as not muted topics
in an unmuted stream.

This commit fixes the incorrect behavior.

Now, for wildcard mentions, 'unread_msgs.mentions' exclude
the IDs in muted streams only if the message is in default or
muted topic.

Also, 'unread_msgs.count' takes into account the unreads in unmuted
or followed topics in muted streams too.

Documents that this bug was fixed in the API changelog.
This commit is contained in:
Prakhar Pratyush
2023-09-25 14:57:15 +05:30
committed by Tim Abbott
parent a18a526427
commit 49092dfa79
7 changed files with 128 additions and 30 deletions

View File

@@ -109,6 +109,21 @@ def set_topic_visibility_policy(
)
def get_topic_visibility_policy(
user_profile: UserProfile,
stream_id: int,
topic_name: str,
) -> int:
try:
user_topic = UserTopic.objects.get(
user_profile=user_profile, stream_id=stream_id, topic_name__iexact=topic_name
)
visibility_policy = user_topic.visibility_policy
except UserTopic.DoesNotExist:
visibility_policy = UserTopic.VisibilityPolicy.INHERIT
return visibility_policy
@transaction.atomic(savepoint=False)
def bulk_set_user_topic_visibility_policy_in_database(
user_profiles: List[UserProfile],