Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
bots: Pass realm to get_system_bot calls in email_mirror.
Mateusz Mandera104139657ba7
diff --git a/zerver/lib/email_mirror.py b/zerver/lib/email_mirror.pyindex b01ccea2860..0fa16a085c7 100644--- a/zerver/lib/email_mirror.py+++ b/zerver/lib/email_mirror.py@@ -228,7 +228,9 @@ def send_mm_reply_to_stream(stream=stream.name, error=error.msg)internal_send_private_message(- get_system_bot(settings.NOTIFICATION_BOT), user_profile, error_message+ get_system_bot(settings.NOTIFICATION_BOT, user_profile.realm_id),+ user_profile,+ error_message,)@@ -326,7 +328,7 @@ def filter_footer(text: str) -> str:def extract_and_upload_attachments(message: EmailMessage, realm: Realm) -> str:- user_profile = get_system_bot(settings.EMAIL_GATEWAY_BOT)+ user_profile = get_system_bot(settings.EMAIL_GATEWAY_BOT, realm.id)attachment_links = []for part in message.walk():@@ -422,7 +424,7 @@ def process_stream_message(to: str, message: EmailMessage) -> None:options["include_quotes"] = is_forwarded(subject_header)body = construct_zulip_body(message, stream.realm, **options)- send_zulip(get_system_bot(settings.EMAIL_GATEWAY_BOT), stream, subject, body)+ send_zulip(get_system_bot(settings.EMAIL_GATEWAY_BOT, stream.realm_id), stream, subject, body)logger.info("Successfully processed email to %s (%s)",stream.name,diff --git a/zerver/tests/test_email_mirror.py b/zerver/tests/test_email_mirror.pyindex ca8187d1e0c..427c320fdcd 100644--- a/zerver/tests/test_email_mirror.py+++ b/zerver/tests/test_email_mirror.py@@ -528,7 +528,7 @@ class TestEmailMirrorMessagesWithAttachments(ZulipTestCase):len(image_bytes),"image/png",image_bytes,- get_system_bot(settings.EMAIL_GATEWAY_BOT),+ get_system_bot(settings.EMAIL_GATEWAY_BOT, stream.realm_id),target_realm=user_profile.realm,)@@ -571,7 +571,7 @@ class TestEmailMirrorMessagesWithAttachments(ZulipTestCase):len(image_bytes),"image/png",image_bytes,- get_system_bot(settings.EMAIL_GATEWAY_BOT),+ get_system_bot(settings.EMAIL_GATEWAY_BOT, stream.realm_id),target_realm=user_profile.realm,)@@ -617,7 +617,7 @@ class TestEmailMirrorMessagesWithAttachments(ZulipTestCase):len(image_bytes),"image/png",image_bytes,- get_system_bot(settings.EMAIL_GATEWAY_BOT),+ get_system_bot(settings.EMAIL_GATEWAY_BOT, stream.realm_id),target_realm=user_profile.realm,)@@ -977,7 +977,9 @@ class TestMissedMessageEmailMessages(ZulipTestCase):message.content,"Error sending message to stream announce via message notification email reply:\nOnly organization administrators can send to this stream.",)- self.assertEqual(message.sender, get_system_bot(settings.NOTIFICATION_BOT))+ self.assertEqual(+ message.sender, get_system_bot(settings.NOTIFICATION_BOT, user_profile.realm_id)+ )def test_missed_stream_message_email_response_tracks_topic_change(self) -> None:self.subscribe(self.example_user("hamlet"), "Denmark")