notification_data: Fix incorrect user_group size being used.

Earlier, in 'get_mentioned_user_group_name()' we were using
'get_user_group_direct_member_ids' function which just checks
the number of direct members and not the recursive membership
of the group.

We should instead use 'get_user_group_member_ids' to calculate
the correct members count of the user group.
This commit is contained in:
Prakhar Pratyush 2024-04-22 14:55:40 +05:30 committed by Tim Abbott
parent 4e5ab739d0
commit e1ad0e87dd
1 changed files with 2 additions and 2 deletions

View File

@ -3,7 +3,7 @@ from dataclasses import dataclass
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.lib.user_groups import get_user_group_member_ids
from zerver.models import UserGroup, UserProfile, UserTopic
from zerver.models.scheduled_jobs import NotificationTriggers
@ -344,7 +344,7 @@ def get_mentioned_user_group_name(
smallest_user_group_name = None
for user_group_id in mentioned_user_group_ids:
current_user_group = UserGroup.objects.get(id=user_group_id, realm=user_profile.realm)
current_user_group_size = len(get_user_group_direct_member_ids(current_user_group))
current_user_group_size = len(get_user_group_member_ids(current_user_group))
if current_user_group_size < smallest_user_group_size:
# If multiple user groups are mentioned, we prefer the