actions: Remove realm argument to internal_send_stream_message.

The argument is redundant.
This commit is contained in:
Mateusz Mandera 2021-02-18 20:14:05 +01:00 committed by Tim Abbott
parent 09fc79f911
commit 51d7f24d20
6 changed files with 6 additions and 21 deletions

View File

@ -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,

View File

@ -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,

View File

@ -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),

View File

@ -220,7 +220,7 @@ class MessagePOSTTest(ZulipTestCase):
# Cross realm bots should be allowed
notification_bot = get_system_bot("notification-bot@zulip.com")
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("notification-bot@zulip.com")
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,

View File

@ -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,

View File

@ -110,7 +110,6 @@ From image editing program:
messages = [
internal_prep_stream_message(
realm,
message["sender"],
stream,
"message formatting",