update-message: Use MentionData in the update_message_backend code.

This is a performance optimization, since we can avoid doing work
related to wildcard mentions in the common case that the message can't
have any.  We also add a unit test for adding wildcard mentions in a
message edit.
This commit is contained in:
Rohitt Vashishtha
2019-11-28 10:26:57 +00:00
committed by Tim Abbott
parent bb42539b3f
commit 68e93d2435
4 changed files with 57 additions and 6 deletions

View File

@@ -4436,7 +4436,7 @@ def do_update_embedded_data(user_profile: UserProfile,
def do_update_message(user_profile: UserProfile, message: Message, topic_name: Optional[str],
propagate_mode: str, content: Optional[str],
rendered_content: Optional[str], prior_mention_user_ids: Set[int],
mention_user_ids: Set[int]) -> int:
mention_user_ids: Set[int], mention_data: Optional[bugdown.MentionData]=None) -> int:
"""
The main function for message editing. A message edit event can
modify:
@@ -4471,6 +4471,9 @@ def do_update_message(user_profile: UserProfile, message: Message, topic_name: O
assert rendered_content is not None
update_user_message_flags(message, ums)
# mention_data is required if there's a content edit.
assert mention_data is not None
# One could imagine checking realm.allow_edit_history here and
# modifying the events based on that setting, but doing so
# doesn't really make sense. We need to send the edit event
@@ -4513,7 +4516,7 @@ def do_update_message(user_profile: UserProfile, message: Message, topic_name: O
recipient=message.recipient,
sender_id=message.sender_id,
stream_topic=stream_topic,
possible_wildcard_mention=True,
possible_wildcard_mention=mention_data.message_has_wildcards(),
)
event['push_notify_user_ids'] = list(info['push_notify_user_ids'])