message: Optimize checking if mentioning user group is allowed.

This commit updates the code to not call is_user_in_group
function if can_mention_group setting is set to "role:everyone"
group.
This commit is contained in:
Sahil Batra
2024-05-18 13:22:33 +05:30
committed by Tim Abbott
parent eec80a4a5a
commit 2007a582a1

View File

@@ -1220,12 +1220,12 @@ def check_user_group_mention_allowed(sender: UserProfile, user_group_ids: List[i
for group in user_groups:
can_mention_group = group.can_mention_group
if sender_is_system_bot:
if (
hasattr(can_mention_group, "named_user_group")
and can_mention_group.named_user_group.name == SystemGroups.EVERYONE
):
continue
if sender_is_system_bot:
raise JsonableError(
_("You are not allowed to mention user group '{user_group_name}'.").format(
user_group_name=group.name