message_edit: Check group mention permission when editing message.

This commit adds backend code to check whether a user is allowed
to mention a user group while editing a message as per
can_mention_group setting of that group.

Fixes a part of #25927.
This commit is contained in:
Sahil Batra
2023-06-14 17:05:54 +05:30
committed by Tim Abbott
parent 1fdffaec73
commit 7aaf34fd7e
2 changed files with 158 additions and 0 deletions

View File

@@ -29,6 +29,7 @@ from zerver.lib.mention import MentionBackend, MentionData, silent_mention_synta
from zerver.lib.message import (
access_message,
bulk_access_messages,
check_user_group_mention_allowed,
normalize_body,
truncate_topic,
update_to_dict_cache,
@@ -1254,6 +1255,10 @@ def check_update_message(
_("You do not have permission to use wildcard mentions in this stream.")
)
if rendering_result.mentions_user_group_ids:
mentioned_group_ids = list(rendering_result.mentions_user_group_ids)
check_user_group_mention_allowed(user_profile, mentioned_group_ids)
new_stream = None
number_changed = 0