render: Upstream calculation of translate_emoticons.

This commit is contained in:
Steve Howell
2018-11-02 11:50:09 +00:00
committed by Tim Abbott
parent b4f2e09b3a
commit 35e9e5928f
2 changed files with 9 additions and 3 deletions

View File

@@ -1917,6 +1917,7 @@ def do_convert(content: str,
message_realm: Optional[Realm]=None,
possible_words: Optional[Set[str]]=None,
sent_by_bot: Optional[bool]=False,
translate_emoticons: Optional[bool]=False,
mention_data: Optional[MentionData]=None,
email_gateway: Optional[bool]=False) -> str:
"""Convert Markdown to HTML, with Zulip-specific settings and hacks."""
@@ -1989,7 +1990,7 @@ def do_convert(content: str,
'realm_uri': message_realm.uri,
'sent_by_bot': sent_by_bot,
'stream_names': stream_name_info,
'translate_emoticons': message.sender.translate_emoticons,
'translate_emoticons': translate_emoticons,
}
try:
@@ -2048,10 +2049,12 @@ def convert(content: str,
message_realm: Optional[Realm]=None,
possible_words: Optional[Set[str]]=None,
sent_by_bot: Optional[bool]=False,
translate_emoticons: Optional[bool]=False,
mention_data: Optional[MentionData]=None,
email_gateway: Optional[bool]=False) -> str:
bugdown_stats_start()
ret = do_convert(content, message, message_realm,
possible_words, sent_by_bot, mention_data, email_gateway)
possible_words, sent_by_bot, translate_emoticons,
mention_data, email_gateway)
bugdown_stats_finish()
return ret

View File

@@ -584,7 +584,9 @@ def render_markdown(message: Message,
if user_id in message_user_ids:
possible_words.update(set(words))
sent_by_bot = get_user_profile_by_id(message.sender_id).is_bot
sender = get_user_profile_by_id(message.sender_id)
sent_by_bot = sender.is_bot
translate_emoticons = sender.translate_emoticons
# DO MAIN WORK HERE -- call bugdown to convert
rendered_content = bugdown.convert(
@@ -593,6 +595,7 @@ def render_markdown(message: Message,
message_realm=realm,
possible_words=possible_words,
sent_by_bot=sent_by_bot,
translate_emoticons=translate_emoticons,
mention_data=mention_data,
email_gateway=email_gateway
)