message: Check wildcard mention restrictions while editing message.

This commit adds code to check whether a user is allowed to use
wildcard mention in a large stream or not while editing a message
based on the realm settings.

Previously this was only checked while sending message, thus user
was easily able to use wildcard mention by first sending a normal
message and then using a wildcard mention by editing it.
This commit is contained in:
Sahil Batra
2021-12-06 23:10:30 +05:30
committed by Tim Abbott
parent fb2d05f9e3
commit b68ebf5a22
2 changed files with 58 additions and 0 deletions

View File

@@ -3068,6 +3068,13 @@ def check_update_message(
)
links_for_embed |= rendering_result.links_for_preview
if message.is_stream_message() and rendering_result.mentions_wildcard:
stream = access_stream_by_id(user_profile, message.recipient.type_id)[0]
if not wildcard_mention_allowed(message.sender, stream):
raise JsonableError(
_("You do not have permission to use wildcard mentions in this stream.")
)
new_stream = None
number_changed = 0