mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 05:53:43 +00:00
message_send: Handle notifications for UNMUTED topic in a muted stream.
This commit adds 'visibility_policy' as a parameter to user_allows_notifications_in_StreamTopic function. This adds logic inside the user_allows_notifications_in_StreamTopic function, to not return False when a stream is muted but the topic is UNMUTED. Adds a method `user_id_to_visibility_policy_dict` to 'StreamTopicTarget' class to fetch (user_id => visibility_policy) in single db query. Co-authored-by: Kartik Srivastava <kaushiksri0908@gmail.com> Co-authored-by: Prakhar Pratyush <prakhar841301@gmail.com>
This commit is contained in:
committed by
Tim Abbott
parent
e9cf2659cf
commit
ce5d13f9b2
@@ -4,7 +4,7 @@ from typing import Any, Collection, Dict, List, Optional, Set
|
||||
|
||||
from zerver.lib.mention import MentionData
|
||||
from zerver.lib.user_groups import get_user_group_direct_member_ids
|
||||
from zerver.models import NotificationTriggers, UserGroup, UserProfile
|
||||
from zerver.models import NotificationTriggers, UserGroup, UserProfile, UserTopic
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -176,15 +176,18 @@ class UserMessageNotificationsData:
|
||||
|
||||
def user_allows_notifications_in_StreamTopic(
|
||||
stream_is_muted: bool,
|
||||
topic_is_muted: bool,
|
||||
visibility_policy: int,
|
||||
stream_specific_setting: Optional[bool],
|
||||
global_setting: bool,
|
||||
) -> bool:
|
||||
"""
|
||||
Captures the hierarchy of notification settings, where muting is considered first, followed
|
||||
by stream-specific settings, and the global-setting in the UserProfile is the fallback.
|
||||
Captures the hierarchy of notification settings, where visibility policy is considered first,
|
||||
followed by stream-specific settings, and the global-setting in the UserProfile is the fallback.
|
||||
"""
|
||||
if stream_is_muted or topic_is_muted:
|
||||
if stream_is_muted and visibility_policy != UserTopic.UNMUTED:
|
||||
return False
|
||||
|
||||
if visibility_policy == UserTopic.MUTED:
|
||||
return False
|
||||
|
||||
if stream_specific_setting is not None:
|
||||
|
||||
Reference in New Issue
Block a user