Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

do_render_markdown: Remove unused message_user_ids parameter.

Anders Kaseorgcfcbf58cd1e0
diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py
index ed197d47b6d..2ef6c032211 100644
--- a/zerver/lib/actions.py
+++ b/zerver/lib/actions.py
@@ -1038,7 +1038,6 @@ def render_incoming_message(message: Message,
content=content,
realm=realm,
realm_alert_words_automaton = realm_alert_words_automaton,
- user_ids=user_ids,
mention_data=mention_data,
email_gateway=email_gateway,
)
diff --git a/zerver/lib/import_realm.py b/zerver/lib/import_realm.py
index ce0f769afb1..ab58601a13c 100644
--- a/zerver/lib/import_realm.py
+++ b/zerver/lib/import_realm.py
@@ -2,7 +2,7 @@ import datetime
import logging
import os
import shutil
-from typing import Any, Dict, Iterable, List, Optional, Set, Tuple, cast
+from typing import Any, Dict, Iterable, List, Optional, Tuple, cast
import boto3
import ujson
@@ -323,14 +323,12 @@ def fix_message_rendered_content(realm: Realm,
# platforms, since they generally don't have an "alert
# words" type feature, and notifications aren't important anyway.
realm_alert_words_automaton = None
- message_user_ids: Set[int] = set()
rendered_content = do_render_markdown(
message=cast(Message, message_object),
content=content,
realm=realm,
realm_alert_words_automaton=realm_alert_words_automaton,
- message_user_ids=message_user_ids,
sent_by_bot=sent_by_bot,
translate_emoticons=translate_emoticons,
)
diff --git a/zerver/lib/message.py b/zerver/lib/message.py
index f8ebc82a345..c76caa751cc 100644
--- a/zerver/lib/message.py
+++ b/zerver/lib/message.py
@@ -658,18 +658,12 @@ def render_markdown(message: Message,
content: str,
realm: Optional[Realm]=None,
realm_alert_words_automaton: Optional[ahocorasick.Automaton]=None,
- user_ids: Optional[Set[int]]=None,
mention_data: Optional[bugdown.MentionData]=None,
email_gateway: bool=False) -> str:
'''
This is basically just a wrapper for do_render_markdown.
'''
- if user_ids is None:
- message_user_ids: Set[int] = set()
- else:
- message_user_ids = user_ids
-
if realm is None:
realm = message.get_realm()
@@ -682,7 +676,6 @@ def render_markdown(message: Message,
content=content,
realm=realm,
realm_alert_words_automaton=realm_alert_words_automaton,
- message_user_ids=message_user_ids,
sent_by_bot=sent_by_bot,
translate_emoticons=translate_emoticons,
mention_data=mention_data,
@@ -694,7 +687,6 @@ def render_markdown(message: Message,
def do_render_markdown(message: Message,
content: str,
realm: Realm,
- message_user_ids: Set[int],
sent_by_bot: bool,
translate_emoticons: bool,
realm_alert_words_automaton: Optional[ahocorasick.Automaton]=None,
diff --git a/zerver/tests/test_bugdown.py b/zerver/tests/test_bugdown.py
index 85618a87394..0809117bd23 100644
--- a/zerver/tests/test_bugdown.py
+++ b/zerver/tests/test_bugdown.py
@@ -1118,8 +1118,7 @@ class BugdownTest(ZulipTestCase):
def render(msg: Message, content: str) -> str:
return render_markdown(msg,
content,
- realm_alert_words_automaton=realm_alert_words_automaton,
- user_ids={user_profile.id})
+ realm_alert_words_automaton=realm_alert_words_automaton)
content = "We have an ALERTWORD day today!"
self.assertEqual(render(msg, content), "<p>We have an ALERTWORD day today!</p>")
@@ -1137,22 +1136,18 @@ class BugdownTest(ZulipTestCase):
'othello': ['how are you'], 'aaron': ['hey'],
}
user_profiles: Dict[str, UserProfile] = {}
- user_ids: Set[int] = set()
for (username, alert_words) in alert_words_for_users.items():
user_profile = self.example_user(username)
user_profiles.update({username: user_profile})
- user_ids.add(user_profile.id)
do_add_alert_words(user_profile, alert_words)
sender_user_profile = self.example_user('polonius')
- user_ids.add(sender_user_profile.id)
msg = Message(sender=sender_user_profile, sending_client=get_client("test"))
realm_alert_words_automaton = get_alert_word_automaton(sender_user_profile.realm)
def render(msg: Message, content: str) -> str:
return render_markdown(msg,
content,
- realm_alert_words_automaton=realm_alert_words_automaton,
- user_ids = user_ids)
+ realm_alert_words_automaton=realm_alert_words_automaton)
content = "hello how is this possible how are you doing today"
render(msg, content)
@@ -1171,22 +1166,18 @@ class BugdownTest(ZulipTestCase):
'othello': ['last'],
}
user_profiles: Dict[str, UserProfile] = {}
- user_ids: Set[int] = set()
for (username, alert_words) in alert_words_for_users.items():
user_profile = self.example_user(username)
user_profiles.update({username: user_profile})
- user_ids.add(user_profile.id)
do_add_alert_words(user_profile, alert_words)
sender_user_profile = self.example_user('polonius')
- user_ids.add(sender_user_profile.id)
msg = Message(sender=sender_user_profile, sending_client=get_client("test"))
realm_alert_words_automaton = get_alert_word_automaton(sender_user_profile.realm)
def render(msg: Message, content: str) -> str:
return render_markdown(msg,
content,
- realm_alert_words_automaton=realm_alert_words_automaton,
- user_ids = user_ids)
+ realm_alert_words_automaton=realm_alert_words_automaton)
content = """Hello, everyone. Prod deployment has been completed
And this is a new line
@@ -1212,22 +1203,18 @@ class BugdownTest(ZulipTestCase):
'othello': ['last'],
}
user_profiles: Dict[str, UserProfile] = {}
- user_ids: Set[int] = set()
for (username, alert_words) in alert_words_for_users.items():
user_profile = self.example_user(username)
user_profiles.update({username: user_profile})
- user_ids.add(user_profile.id)
do_add_alert_words(user_profile, alert_words)
sender_user_profile = self.example_user('polonius')
- user_ids.add(sender_user_profile.id)
msg = Message(sender=sender_user_profile, sending_client=get_client("test"))
realm_alert_words_automaton = get_alert_word_automaton(sender_user_profile.realm)
def render(msg: Message, content: str) -> str:
return render_markdown(msg,
content,
- realm_alert_words_automaton=realm_alert_words_automaton,
- user_ids = user_ids)
+ realm_alert_words_automaton=realm_alert_words_automaton)
content = """This is to test out alert words work in languages with accented characters too
bonjour est (énormément) ce a quoi ressemble le français
@@ -1244,7 +1231,6 @@ class BugdownTest(ZulipTestCase):
'othello': [], 'aaron': [],
}
user_profiles: Dict[str, UserProfile] = {}
- user_ids: Set[int] = set()
for (username, alert_words) in alert_words_for_users.items():
user_profile = self.example_user(username)
user_profiles.update({username: user_profile})
@@ -1256,8 +1242,7 @@ class BugdownTest(ZulipTestCase):
def render(msg: Message, content: str) -> str:
return render_markdown(msg,
content,
- realm_alert_words_automaton=realm_alert_words_automaton,
- user_ids = user_ids)
+ realm_alert_words_automaton=realm_alert_words_automaton)
content = """hello how is this possible how are you doing today
This is to test that the no user_ids who have alrert wourldword is participating
@@ -1280,21 +1265,18 @@ class BugdownTest(ZulipTestCase):
'othello': [],
}
user_profiles: Dict[str, UserProfile] = {}
- user_ids: Set[int] = set()
for (username, alert_words) in alert_words_for_users.items():
user_profile = self.example_user(username)
user_profiles.update({username: user_profile})
do_add_alert_words(user_profile, alert_words)
sender_user_profile = self.example_user('polonius')
- user_ids = {user_profiles['hamlet'].id, user_profiles['iago'].id, user_profiles['othello'].id}
msg = Message(sender=sender_user_profile, sending_client=get_client("test"))
realm_alert_words_automaton = get_alert_word_automaton(sender_user_profile.realm)
def render(msg: Message, content: str) -> str:
return render_markdown(msg,
content,
- realm_alert_words_automaton=realm_alert_words_automaton,
- user_ids = user_ids)
+ realm_alert_words_automaton=realm_alert_words_automaton)
content = """This is to test a empty alert words i.e. no user has any alert-words set"""
render(msg, content)
@@ -1310,21 +1292,18 @@ class BugdownTest(ZulipTestCase):
'othello': self.get_mock_alert_words(500, 10),
}
user_profiles: Dict[str, UserProfile] = {}
- user_ids: Set[int] = set()
for (username, alert_words) in alert_words_for_users.items():
user_profile = self.example_user(username)
user_profiles.update({username: user_profile})
do_add_alert_words(user_profile, alert_words)
sender_user_profile = self.example_user('polonius')
- user_ids = {user_profiles['hamlet'].id, user_profiles['iago'].id, user_profiles['othello'].id}
msg = Message(sender=sender_user_profile, sending_client=get_client("test"))
realm_alert_words_automaton = get_alert_word_automaton(sender_user_profile.realm)
def render(msg: Message, content: str) -> str:
return render_markdown(msg,
content,
- realm_alert_words_automaton=realm_alert_words_automaton,
- user_ids = user_ids)
+ realm_alert_words_automaton=realm_alert_words_automaton)
content = """The code above will print 10 random values of numbers between 1 and 100.
The second line, for x in range(10), determines how many values will be printed (when you use