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.

message: Access realm from SendMessageRequest object directly.

Sahil Batradf2407f97a04
diff --git a/zerver/actions/message_send.py b/zerver/actions/message_send.py
index 4cd1ce66595..9d1ada3d5a0 100644
--- a/zerver/actions/message_send.py
+++ b/zerver/actions/message_send.py
@@ -986,7 +986,7 @@ def do_send_messages(
]
presence_idle_user_ids = get_active_presence_idle_user_ids(
- realm=sender.realm,
+ realm=send_request.realm,
sender_id=sender.id,
user_notifications_data_list=user_notifications_data_list,
)
@@ -1051,9 +1051,7 @@ def do_send_messages(
queue_json_publish("embed_links", event_data)
if send_request.message.recipient.type == Recipient.PERSONAL:
- welcome_bot_id = get_system_bot(
- settings.WELCOME_BOT, send_request.message.sender.realm_id
- ).id
+ welcome_bot_id = get_system_bot(settings.WELCOME_BOT, send_request.realm.id).id
if (
welcome_bot_id in send_request.active_user_ids
and welcome_bot_id != send_request.message.sender_id
diff --git a/zerver/lib/onboarding.py b/zerver/lib/onboarding.py
index d948e1677c2..a438c98bf27 100644
--- a/zerver/lib/onboarding.py
+++ b/zerver/lib/onboarding.py
@@ -245,7 +245,7 @@ def select_welcome_bot_response(human_response_lower: str) -> str:
def send_welcome_bot_response(send_request: SendMessageRequest) -> None:
"""Given the send_request object for a direct message from the user
to welcome-bot, trigger the welcome-bot reply."""
- welcome_bot = get_system_bot(settings.WELCOME_BOT, send_request.message.sender.realm_id)
+ welcome_bot = get_system_bot(settings.WELCOME_BOT, send_request.realm.id)
human_response_lower = send_request.message.content.lower()
content = select_welcome_bot_response(human_response_lower)