mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 01:16:19 +00:00
Speed up alert word detection during message sends.
We no longer use all the alert words for all the users in the entire realm when we look for alert words in a newly sent/edited message. Now we limit the search to only all the alert words for all the users who will get UserMessage records. This will hopefully make a big difference for big realms where most messages are only sent to a small subset of users.
This commit is contained in:
@@ -628,13 +628,14 @@ def do_send_message(message, rendered_content = None, no_log = False, stream = N
|
||||
'stream': stream,
|
||||
'local_id': local_id}])[0]
|
||||
|
||||
def render_incoming_message(message, content):
|
||||
# type: (Message, text_type) -> text_type
|
||||
def render_incoming_message(message, content, message_users):
|
||||
# type: (Message, text_type, Set[UserProfile]) -> text_type
|
||||
realm_alert_words = alert_words_in_realm(message.get_realm())
|
||||
try:
|
||||
rendered_content = message.render_markdown(
|
||||
content=content,
|
||||
realm_alert_words=realm_alert_words,
|
||||
message_users=message_users,
|
||||
)
|
||||
except BugdownRenderingException:
|
||||
raise JsonableError(_('Unable to render message'))
|
||||
@@ -704,7 +705,8 @@ def do_send_messages(messages):
|
||||
assert message['message'].rendered_content is None
|
||||
rendered_content = render_incoming_message(
|
||||
message['message'],
|
||||
message['message'].content)
|
||||
message['message'].content,
|
||||
message_users=message['active_recipients'])
|
||||
message['message'].set_rendered_content(rendered_content)
|
||||
|
||||
for message in messages:
|
||||
|
||||
Reference in New Issue
Block a user