mirror of
https://github.com/zulip/zulip.git
synced 2025-11-18 04:43:58 +00:00
actions: Remove realm argument to internal_send_stream_message.
The argument is redundant.
This commit is contained in:
committed by
Tim Abbott
parent
09fc79f911
commit
51d7f24d20
@@ -377,9 +377,7 @@ def notify_new_user(user_profile: UserProfile) -> None:
|
|||||||
message = _("{user} just signed up for Zulip. (total: {user_count})").format(
|
message = _("{user} just signed up for Zulip. (total: {user_count})").format(
|
||||||
user=f"@_**{user_profile.full_name}|{user_profile.id}**", user_count=user_count
|
user=f"@_**{user_profile.full_name}|{user_profile.id}**", user_count=user_count
|
||||||
)
|
)
|
||||||
internal_send_stream_message(
|
internal_send_stream_message(sender, signup_notifications_stream, _("signups"), message)
|
||||||
user_profile.realm, sender, signup_notifications_stream, _("signups"), message
|
|
||||||
)
|
|
||||||
|
|
||||||
# We also send a notification to the Zulip administrative realm
|
# We also send a notification to the Zulip administrative realm
|
||||||
admin_realm = sender.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
|
user=f"{user_profile.full_name} <`{user_profile.email}`>", user_count=user_count
|
||||||
)
|
)
|
||||||
internal_send_stream_message(
|
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:
|
except Stream.DoesNotExist:
|
||||||
@@ -2860,7 +2858,6 @@ def _internal_prep_message(
|
|||||||
|
|
||||||
|
|
||||||
def internal_prep_stream_message(
|
def internal_prep_stream_message(
|
||||||
realm: Realm,
|
|
||||||
sender: UserProfile,
|
sender: UserProfile,
|
||||||
stream: Stream,
|
stream: Stream,
|
||||||
topic: str,
|
topic: str,
|
||||||
@@ -2870,6 +2867,7 @@ def internal_prep_stream_message(
|
|||||||
"""
|
"""
|
||||||
See _internal_prep_message for details of how this works.
|
See _internal_prep_message for details of how this works.
|
||||||
"""
|
"""
|
||||||
|
realm = stream.realm
|
||||||
addressee = Addressee.for_stream(stream, topic)
|
addressee = Addressee.for_stream(stream, topic)
|
||||||
|
|
||||||
return _internal_prep_message(
|
return _internal_prep_message(
|
||||||
@@ -2929,7 +2927,6 @@ def internal_send_private_message(
|
|||||||
|
|
||||||
|
|
||||||
def internal_send_stream_message(
|
def internal_send_stream_message(
|
||||||
realm: Realm,
|
|
||||||
sender: UserProfile,
|
sender: UserProfile,
|
||||||
stream: Stream,
|
stream: Stream,
|
||||||
topic: str,
|
topic: str,
|
||||||
@@ -2937,7 +2934,7 @@ def internal_send_stream_message(
|
|||||||
email_gateway: bool = False,
|
email_gateway: bool = False,
|
||||||
) -> Optional[int]:
|
) -> 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:
|
if message is None:
|
||||||
return 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)
|
sender = get_system_bot(settings.NOTIFICATION_BOT)
|
||||||
with override_language(stream.realm.default_language):
|
with override_language(stream.realm.default_language):
|
||||||
internal_send_stream_message(
|
internal_send_stream_message(
|
||||||
stream.realm,
|
|
||||||
sender,
|
sender,
|
||||||
stream,
|
stream,
|
||||||
Realm.STREAM_EVENTS_NOTIFICATION_TOPIC,
|
Realm.STREAM_EVENTS_NOTIFICATION_TOPIC,
|
||||||
@@ -4419,7 +4415,6 @@ def do_create_realm(
|
|||||||
topic = realm.display_subdomain
|
topic = realm.display_subdomain
|
||||||
|
|
||||||
internal_send_stream_message(
|
internal_send_stream_message(
|
||||||
admin_realm,
|
|
||||||
sender,
|
sender,
|
||||||
signups_stream,
|
signups_stream,
|
||||||
topic,
|
topic,
|
||||||
@@ -5121,7 +5116,6 @@ def send_message_moved_breadcrumbs(
|
|||||||
if send_notification_to_new_thread:
|
if send_notification_to_new_thread:
|
||||||
with override_language(new_stream.realm.default_language):
|
with override_language(new_stream.realm.default_language):
|
||||||
internal_send_stream_message(
|
internal_send_stream_message(
|
||||||
new_stream.realm,
|
|
||||||
sender,
|
sender,
|
||||||
new_stream,
|
new_stream,
|
||||||
new_topic,
|
new_topic,
|
||||||
@@ -5135,7 +5129,6 @@ def send_message_moved_breadcrumbs(
|
|||||||
with override_language(old_stream.realm.default_language):
|
with override_language(old_stream.realm.default_language):
|
||||||
# Send a notification to the old stream that the topic was moved.
|
# Send a notification to the old stream that the topic was moved.
|
||||||
internal_send_stream_message(
|
internal_send_stream_message(
|
||||||
old_stream.realm,
|
|
||||||
sender,
|
sender,
|
||||||
old_stream,
|
old_stream,
|
||||||
old_topic,
|
old_topic,
|
||||||
|
|||||||
@@ -202,7 +202,6 @@ class ZulipEmailForwardUserError(ZulipEmailForwardError):
|
|||||||
|
|
||||||
def send_zulip(sender: UserProfile, stream: Stream, topic: str, content: str) -> None:
|
def send_zulip(sender: UserProfile, stream: Stream, topic: str, content: str) -> None:
|
||||||
internal_send_stream_message(
|
internal_send_stream_message(
|
||||||
stream.realm,
|
|
||||||
sender,
|
sender,
|
||||||
stream,
|
stream,
|
||||||
truncate_topic(topic),
|
truncate_topic(topic),
|
||||||
@@ -431,7 +430,6 @@ def process_missed_message(to: str, message: EmailMessage) -> None:
|
|||||||
if recipient.type == Recipient.STREAM:
|
if recipient.type == Recipient.STREAM:
|
||||||
stream = get_stream_by_id_in_realm(recipient.type_id, user_profile.realm)
|
stream = get_stream_by_id_in_realm(recipient.type_id, user_profile.realm)
|
||||||
internal_send_stream_message(
|
internal_send_stream_message(
|
||||||
user_profile.realm,
|
|
||||||
user_profile,
|
user_profile,
|
||||||
stream,
|
stream,
|
||||||
topic,
|
topic,
|
||||||
|
|||||||
@@ -96,7 +96,6 @@ def zulip_browser_error(report: Dict[str, Any]) -> None:
|
|||||||
errors_stream = get_stream("errors", realm)
|
errors_stream = get_stream("errors", realm)
|
||||||
|
|
||||||
internal_send_stream_message(
|
internal_send_stream_message(
|
||||||
realm,
|
|
||||||
error_bot,
|
error_bot,
|
||||||
errors_stream,
|
errors_stream,
|
||||||
format_email_subject(email_subject),
|
format_email_subject(email_subject),
|
||||||
@@ -151,7 +150,6 @@ Error generated by {user_info}
|
|||||||
errors_stream = get_stream("errors", realm)
|
errors_stream = get_stream("errors", realm)
|
||||||
|
|
||||||
internal_send_stream_message(
|
internal_send_stream_message(
|
||||||
realm,
|
|
||||||
error_bot,
|
error_bot,
|
||||||
errors_stream,
|
errors_stream,
|
||||||
format_email_subject(email_subject),
|
format_email_subject(email_subject),
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ class MessagePOSTTest(ZulipTestCase):
|
|||||||
# Cross realm bots should be allowed
|
# Cross realm bots should be allowed
|
||||||
notification_bot = get_system_bot("notification-bot@zulip.com")
|
notification_bot = get_system_bot("notification-bot@zulip.com")
|
||||||
internal_send_stream_message(
|
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")
|
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
|
# Cross realm bots should be allowed
|
||||||
notification_bot = get_system_bot("notification-bot@zulip.com")
|
notification_bot = get_system_bot("notification-bot@zulip.com")
|
||||||
internal_send_stream_message(
|
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")
|
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:
|
with self.assertLogs(level="ERROR") as m:
|
||||||
internal_send_stream_message(
|
internal_send_stream_message(
|
||||||
realm=realm,
|
|
||||||
sender=cordelia,
|
sender=cordelia,
|
||||||
topic="whatever",
|
topic="whatever",
|
||||||
content=bad_content,
|
content=bad_content,
|
||||||
|
|||||||
@@ -640,7 +640,6 @@ def send_messages_for_new_subscribers(
|
|||||||
|
|
||||||
notifications.append(
|
notifications.append(
|
||||||
internal_prep_stream_message(
|
internal_prep_stream_message(
|
||||||
realm=user_profile.realm,
|
|
||||||
sender=sender,
|
sender=sender,
|
||||||
stream=notifications_stream,
|
stream=notifications_stream,
|
||||||
topic=topic,
|
topic=topic,
|
||||||
@@ -654,7 +653,6 @@ def send_messages_for_new_subscribers(
|
|||||||
with override_language(stream.realm.default_language):
|
with override_language(stream.realm.default_language):
|
||||||
notifications.append(
|
notifications.append(
|
||||||
internal_prep_stream_message(
|
internal_prep_stream_message(
|
||||||
realm=user_profile.realm,
|
|
||||||
sender=sender,
|
sender=sender,
|
||||||
stream=stream,
|
stream=stream,
|
||||||
topic=Realm.STREAM_EVENTS_NOTIFICATION_TOPIC,
|
topic=Realm.STREAM_EVENTS_NOTIFICATION_TOPIC,
|
||||||
|
|||||||
@@ -110,7 +110,6 @@ From image editing program:
|
|||||||
|
|
||||||
messages = [
|
messages = [
|
||||||
internal_prep_stream_message(
|
internal_prep_stream_message(
|
||||||
realm,
|
|
||||||
message["sender"],
|
message["sender"],
|
||||||
stream,
|
stream,
|
||||||
"message formatting",
|
"message formatting",
|
||||||
|
|||||||
Reference in New Issue
Block a user