Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
actions: Remove realm argument to internal_send_private_message.
Mateusz Mandera09fc79f911fb
diff --git a/corporate/lib/stripe.py b/corporate/lib/stripe.pyindex 0eced6e9856..05241c4ee9c 100644--- a/corporate/lib/stripe.py+++ b/corporate/lib/stripe.py@@ -769,9 +769,7 @@ def approve_sponsorship(realm: Realm) -> None:f"Your organization's request for sponsored hosting has been approved! {emoji}.\n"f"You have been upgraded to {plan_name}, free of charge.")- internal_send_private_message(- billing_admin.realm, notification_bot, billing_admin, message- )+ internal_send_private_message(notification_bot, billing_admin, message)def get_discount_for_realm(realm: Realm) -> Optional[Decimal]:diff --git a/zerver/lib/actions.py b/zerver/lib/actions.pyindex 0cd33d61d30..69bebecc2ca 100644--- a/zerver/lib/actions.py+++ b/zerver/lib/actions.py@@ -495,7 +495,6 @@ def process_new_human_user(# This is a cross-realm private message.with override_language(prereg_user.referred_by.default_language):internal_send_private_message(- realm,get_system_bot(settings.NOTIFICATION_BOT),prereg_user.referred_by,_("{user} accepted your invitation to join Zulip!").format(@@ -2575,7 +2574,7 @@ def send_rate_limited_pm_notification_to_bot_owner(returninternal_send_private_message(- realm, get_system_bot(settings.NOTIFICATION_BOT), sender.bot_owner, content+ get_system_bot(settings.NOTIFICATION_BOT), sender.bot_owner, content)sender.last_reminder = timezone_now()@@ -2919,8 +2918,9 @@ def internal_prep_private_message(def internal_send_private_message(- realm: Realm, sender: UserProfile, recipient_user: UserProfile, content: str+ sender: UserProfile, recipient_user: UserProfile, content: str) -> Optional[int]:+ realm = recipient_user.realmmessage = internal_prep_private_message(realm, sender, recipient_user, content)if message is None:return Nonediff --git a/zerver/lib/bot_lib.py b/zerver/lib/bot_lib.pyindex fcab7c123e9..420883b4412 100644--- a/zerver/lib/bot_lib.py+++ b/zerver/lib/bot_lib.py@@ -102,9 +102,7 @@ class EmbeddedBotHandler:raise EmbeddedBotEmptyRecipientsList(_("Message must have recipients!"))elif len(message["to"]) == 1:recipient_user = get_active_user(recipients[0], self.user_profile.realm)- internal_send_private_message(- self.user_profile.realm, self.user_profile, recipient_user, message["content"]- )+ internal_send_private_message(self.user_profile, recipient_user, message["content"])else:internal_send_huddle_message(self.user_profile.realm, self.user_profile, recipients, message["content"]diff --git a/zerver/lib/email_mirror.py b/zerver/lib/email_mirror.pyindex 0c4440cdae3..9a656d411d4 100644--- a/zerver/lib/email_mirror.py+++ b/zerver/lib/email_mirror.py@@ -443,7 +443,7 @@ def process_missed_message(to: str, message: EmailMessage) -> None:assert not isinstance(display_recipient, str)recipient_str = display_recipient[0]["email"]recipient_user = get_user(recipient_str, user_profile.realm)- internal_send_private_message(user_profile.realm, user_profile, recipient_user, body)+ internal_send_private_message(user_profile, recipient_user, body)elif recipient.type == Recipient.HUDDLE:display_recipient = get_display_recipient(recipient)assert not isinstance(display_recipient, str)diff --git a/zerver/lib/onboarding.py b/zerver/lib/onboarding.pyindex 86eb9432814..bcc5b903743 100644--- a/zerver/lib/onboarding.py+++ b/zerver/lib/onboarding.py@@ -96,7 +96,7 @@ def send_initial_pms(user: UserProfile) -> None:apps_url="/apps", settings_url="#settings", organization_setup_text=organization_setup_text)- internal_send_private_message(user.realm, get_system_bot(settings.WELCOME_BOT), user, content)+ internal_send_private_message(get_system_bot(settings.WELCOME_BOT), user, content)def send_welcome_bot_response(send_request: SendMessageRequest) -> None:@@ -113,9 +113,7 @@ def send_welcome_bot_response(send_request: SendMessageRequest) -> None:"skills. Or, try clicking on some of the stream names to your left!"))- internal_send_private_message(- send_request.realm, welcome_bot, send_request.message.sender, content- )+ internal_send_private_message(welcome_bot, send_request.message.sender, content)def send_initial_realm_messages(realm: Realm) -> None:diff --git a/zerver/tests/test_message_send.py b/zerver/tests/test_message_send.pyindex 1daee9f72f1..42629310c9d 100644--- a/zerver/tests/test_message_send.py+++ b/zerver/tests/test_message_send.py@@ -1983,7 +1983,6 @@ class InternalPrepTest(ZulipTestCase):with self.assertLogs(level="ERROR") as m:internal_send_private_message(- realm=realm,sender=cordelia,recipient_user=hamlet,content=bad_content,@@ -2149,7 +2148,6 @@ class TestCrossRealmPMs(ZulipTestCase):# Cross-realm bots in the zulip.com realm can PM any realm# (They need lower level APIs to do this.)internal_send_private_message(- realm=r2,sender=get_system_bot(notification_bot_email),recipient_user=get_user(user2_email, r2),content="bla",diff --git a/zerver/tests/test_retention.py b/zerver/tests/test_retention.pyindex 897830a8c98..51d8ee3316b 100644--- a/zerver/tests/test_retention.py+++ b/zerver/tests/test_retention.py@@ -137,7 +137,6 @@ class ArchiveMessagesTestingBase(RetentionTestingBase):get_user_profile_by_email(bot_email)zulip_user = self.example_user("hamlet")msg_id = internal_send_private_message(- realm=self.zulip_realm,sender=get_system_bot(bot_email),recipient_user=zulip_user,content="test message",diff --git a/zerver/tests/test_tutorial.py b/zerver/tests/test_tutorial.pyindex 9a1b706259b..fd3507498a9 100644--- a/zerver/tests/test_tutorial.py+++ b/zerver/tests/test_tutorial.py@@ -16,7 +16,7 @@ class TutorialTests(ZulipTestCase):user = self.example_user("hamlet")welcome_bot = get_system_bot(settings.WELCOME_BOT)content = "Shortened welcome message."- internal_send_private_message(user.realm, welcome_bot, user, content)+ internal_send_private_message(welcome_bot, user, content)def test_tutorial_status(self) -> None:user = self.example_user("hamlet")diff --git a/zerver/tests/test_upload.py b/zerver/tests/test_upload.pyindex 170c568aeae..382dda05e0f 100644--- a/zerver/tests/test_upload.py+++ b/zerver/tests/test_upload.py@@ -584,7 +584,6 @@ class FileUploadTest(UploadSerializeMixin, ZulipTestCase):body = f"First message ...[zulip.txt](http://{host}/user_uploads/" + fp_path_id + ")"with self.settings(CROSS_REALM_BOT_EMAILS={user_2.email, user_3.email}):internal_send_private_message(- realm=r1,sender=get_system_bot(user_2.email),recipient_user=user_1,content=body,diff --git a/zerver/worker/queue_processors.py b/zerver/worker/queue_processors.pyindex e0ca0c91f2a..9e01f9c2d01 100644--- a/zerver/worker/queue_processors.py+++ b/zerver/worker/queue_processors.py@@ -887,7 +887,6 @@ class DeferredWorker(QueueProcessingWorker):"Your data export is complete and has been uploaded here:\n\n{public_url}").format(public_url=public_url)internal_send_private_message(- realm=user_profile.realm,sender=get_system_bot(settings.NOTIFICATION_BOT),recipient_user=user_profile,content=content,