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.

actions: Remove realm argument to internal_send_stream_message.

Mateusz Mandera51d7f24d20e3
diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py
index 69bebecc2ca..b4b10ef5505 100644
--- a/zerver/lib/actions.py
+++ b/zerver/lib/actions.py
@@ -377,9 +377,7 @@ def notify_new_user(user_profile: UserProfile) -> None:
message = _("{user} just signed up for Zulip. (total: {user_count})").format(
user=f"@_**{user_profile.full_name}|{user_profile.id}**", user_count=user_count
)
- internal_send_stream_message(
- user_profile.realm, sender, signup_notifications_stream, _("signups"), message
- )
+ internal_send_stream_message(sender, signup_notifications_stream, _("signups"), message)
# We also send a notification to the Zulip administrative realm
admin_realm = sender.realm
@@ -392,7 +390,7 @@ def notify_new_user(user_profile: UserProfile) -> None:
user=f"{user_profile.full_name} <`{user_profile.email}`>", user_count=user_count
)
internal_send_stream_message(
- admin_realm, sender, signups_stream, user_profile.realm.display_subdomain, message
+ sender, signups_stream, user_profile.realm.display_subdomain, message
)
except Stream.DoesNotExist:
@@ -2860,7 +2858,6 @@ def _internal_prep_message(
def internal_prep_stream_message(
- realm: Realm,
sender: UserProfile,
stream: Stream,
topic: str,
@@ -2870,6 +2867,7 @@ def internal_prep_stream_message(
"""
See _internal_prep_message for details of how this works.
"""
+ realm = stream.realm
addressee = Addressee.for_stream(stream, topic)
return _internal_prep_message(
@@ -2929,7 +2927,6 @@ def internal_send_private_message(
def internal_send_stream_message(
- realm: Realm,
sender: UserProfile,
stream: Stream,
topic: str,
@@ -2937,7 +2934,7 @@ def internal_send_stream_message(
email_gateway: bool = False,
) -> Optional[int]:
- message = internal_prep_stream_message(realm, sender, stream, topic, content, email_gateway)
+ message = internal_prep_stream_message(sender, stream, topic, content, email_gateway)
if message is None:
return None
@@ -4317,7 +4314,6 @@ def do_rename_stream(stream: Stream, new_name: str, user_profile: UserProfile) -
sender = get_system_bot(settings.NOTIFICATION_BOT)
with override_language(stream.realm.default_language):
internal_send_stream_message(
- stream.realm,
sender,
stream,
Realm.STREAM_EVENTS_NOTIFICATION_TOPIC,
@@ -4419,7 +4415,6 @@ def do_create_realm(
topic = realm.display_subdomain
internal_send_stream_message(
- admin_realm,
sender,
signups_stream,
topic,
@@ -5121,7 +5116,6 @@ def send_message_moved_breadcrumbs(
if send_notification_to_new_thread:
with override_language(new_stream.realm.default_language):
internal_send_stream_message(
- new_stream.realm,
sender,
new_stream,
new_topic,
@@ -5135,7 +5129,6 @@ def send_message_moved_breadcrumbs(
with override_language(old_stream.realm.default_language):
# Send a notification to the old stream that the topic was moved.
internal_send_stream_message(
- old_stream.realm,
sender,
old_stream,
old_topic,
diff --git a/zerver/lib/email_mirror.py b/zerver/lib/email_mirror.py
index 9a656d411d4..5ccb0fd0e46 100644
--- a/zerver/lib/email_mirror.py
+++ b/zerver/lib/email_mirror.py
@@ -202,7 +202,6 @@ class ZulipEmailForwardUserError(ZulipEmailForwardError):
def send_zulip(sender: UserProfile, stream: Stream, topic: str, content: str) -> None:
internal_send_stream_message(
- stream.realm,
sender,
stream,
truncate_topic(topic),
@@ -431,7 +430,6 @@ def process_missed_message(to: str, message: EmailMessage) -> None:
if recipient.type == Recipient.STREAM:
stream = get_stream_by_id_in_realm(recipient.type_id, user_profile.realm)
internal_send_stream_message(
- user_profile.realm,
user_profile,
stream,
topic,
diff --git a/zerver/lib/error_notify.py b/zerver/lib/error_notify.py
index 83346ab559e..808cb290bd9 100644
--- a/zerver/lib/error_notify.py
+++ b/zerver/lib/error_notify.py
@@ -96,7 +96,6 @@ def zulip_browser_error(report: Dict[str, Any]) -> None:
errors_stream = get_stream("errors", realm)
internal_send_stream_message(
- realm,
error_bot,
errors_stream,
format_email_subject(email_subject),
@@ -151,7 +150,6 @@ Error generated by {user_info}
errors_stream = get_stream("errors", realm)
internal_send_stream_message(
- realm,
error_bot,
errors_stream,
format_email_subject(email_subject),
diff --git a/zerver/tests/test_message_send.py b/zerver/tests/test_message_send.py
index 42629310c9d..664ed1e8a7e 100644
--- a/zerver/tests/test_message_send.py
+++ b/zerver/tests/test_message_send.py
@@ -220,7 +220,7 @@ class MessagePOSTTest(ZulipTestCase):
# Cross realm bots should be allowed
notification_bot = get_system_bot("[email protected]")
internal_send_stream_message(
- stream.realm, notification_bot, stream, "Test topic", "Test message by notification bot"
+ notification_bot, stream, "Test topic", "Test message by notification bot"
)
self.assertEqual(self.get_last_message().content, "Test message by notification bot")
@@ -305,7 +305,7 @@ class MessagePOSTTest(ZulipTestCase):
# Cross realm bots should be allowed
notification_bot = get_system_bot("[email protected]")
internal_send_stream_message(
- stream.realm, notification_bot, stream, "Test topic", "Test message by notification bot"
+ notification_bot, stream, "Test topic", "Test message by notification bot"
)
self.assertEqual(self.get_last_message().content, "Test message by notification bot")
@@ -2012,7 +2012,6 @@ class InternalPrepTest(ZulipTestCase):
with self.assertLogs(level="ERROR") as m:
internal_send_stream_message(
- realm=realm,
sender=cordelia,
topic="whatever",
content=bad_content,
diff --git a/zerver/views/streams.py b/zerver/views/streams.py
index d4e88ff9f48..36ca0b9b29b 100644
--- a/zerver/views/streams.py
+++ b/zerver/views/streams.py
@@ -640,7 +640,6 @@ def send_messages_for_new_subscribers(
notifications.append(
internal_prep_stream_message(
- realm=user_profile.realm,
sender=sender,
stream=notifications_stream,
topic=topic,
@@ -654,7 +653,6 @@ def send_messages_for_new_subscribers(
with override_language(stream.realm.default_language):
notifications.append(
internal_prep_stream_message(
- realm=user_profile.realm,
sender=sender,
stream=stream,
topic=Realm.STREAM_EVENTS_NOTIFICATION_TOPIC,
diff --git a/zilencer/management/commands/add_mock_conversation.py b/zilencer/management/commands/add_mock_conversation.py
index f50ff97d81d..c94faacff6c 100644
--- a/zilencer/management/commands/add_mock_conversation.py
+++ b/zilencer/management/commands/add_mock_conversation.py
@@ -110,7 +110,6 @@ From image editing program:
messages = [
internal_prep_stream_message(
- realm,
message["sender"],
stream,
"message formatting",