From c6c3cda089ad78c6c47cac39ad1e88c64cdac1fb Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Mon, 18 Mar 2013 10:58:13 -0400 Subject: [PATCH] do_send_message: Save a database query on message sending. (imported from commit c5dc3d9888f9b1867e8d20d84795dde32cf95583) --- zephyr/lib/actions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zephyr/lib/actions.py b/zephyr/lib/actions.py index fe1690e3b8..e4833a677b 100644 --- a/zephyr/lib/actions.py +++ b/zephyr/lib/actions.py @@ -179,7 +179,7 @@ def do_send_message(message, rendered_content=None, no_log=False): # notify_new_message request if it's a public stream, # ensuring that in the tornado server, non-public stream # messages are only associated to their subscribed users. - stream = Stream.objects.get(id=message.recipient.type_id) + stream = Stream.objects.select_related("realm").get(id=message.recipient.type_id) if stream.is_public(): data['realm_id'] = stream.realm.id data['stream_name'] = stream.name