message_send: Fix checking permission to send DMs.

This commit fixes the code to add a check for whether the
setting is set to an anonymous group or not before checking
if the setting is set to "Nobody" group by checking the
group name.
This commit is contained in:
Sahil Batra
2024-12-06 09:40:13 +05:30
committed by Tim Abbott
parent 3bad36ef8c
commit 118e6c36f8

View File

@@ -1565,7 +1565,8 @@ def check_can_send_direct_message(
user_ids = [recipient_user.id for recipient_user in recipient_users] + [sender.id]
if not is_any_user_in_group(direct_message_permission_group, user_ids):
is_nobody_group = (
direct_message_permission_group.named_user_group.name == SystemGroups.NOBODY
hasattr(direct_message_permission_group, "named_user_group")
and direct_message_permission_group.named_user_group.name == SystemGroups.NOBODY
)
raise DirectMessagePermissionError(is_nobody_group)