actions: Modify check_message for handling wildcard_mention_policy setting.

This commit adds enforcement for sending messages containing wildcard
mentions according to wildcard_mention_policy.
This commit is contained in:
sahil839
2020-09-11 19:41:06 +05:30
committed by Tim Abbott
parent 25f32d461e
commit d0f5537fb2
5 changed files with 151 additions and 2 deletions

View File

@@ -103,6 +103,7 @@ from zerver.lib.message import (
truncate_body,
truncate_topic,
update_first_visible_message_id,
wildcard_mention_allowed,
)
from zerver.lib.pysa import mark_sanitized
from zerver.lib.queue import queue_json_publish
@@ -2416,7 +2417,12 @@ def check_message(sender: UserProfile, client: Client, addressee: Addressee,
message_dict = {'message': message, 'stream': stream, 'local_id': local_id,
'sender_queue_id': sender_queue_id, 'realm': realm,
'widget_content': widget_content}
return build_message_send_dict(message_dict, email_gateway)
message_send_dict = build_message_send_dict(message_dict, email_gateway)
if stream is not None and message_send_dict['message'].mentions_wildcard:
if not wildcard_mention_allowed(sender, stream):
raise JsonableError(_("You do not have permission to use wildcard mentions in this stream."))
return message_send_dict
def _internal_prep_message(realm: Realm,
sender: UserProfile,