From e0f30d02f2acea4292ac82187d66a512e2aa1b40 Mon Sep 17 00:00:00 2001 From: Umair Khan Date: Wed, 29 Nov 2017 12:34:09 +0500 Subject: [PATCH] email-worker: Send login email through queue. Fixes #7460 --- zerver/signals.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/zerver/signals.py b/zerver/signals.py index 24e0492705..f4332e0627 100644 --- a/zerver/signals.py +++ b/zerver/signals.py @@ -9,6 +9,7 @@ from django.utils.timezone import \ get_current_timezone_name as timezone_get_current_timezone_name from django.utils.timezone import now as timezone_now +from zerver.lib.queue import queue_json_publish from zerver.lib.send_email import FromAddress, send_email from zerver.models import UserProfile @@ -82,6 +83,10 @@ def email_on_new_login(sender: Any, user: UserProfile, request: Any, **kwargs: A context['device_info'] = device_info context['user'] = user - send_email('zerver/emails/notify_new_login', to_user_id=user.id, - from_name='Zulip Account Security', from_address=FromAddress.NOREPLY, - context=context) + email_dict = { + 'template_prefix': 'zerver/emails/notify_new_login', + 'to_user_id': user.id, + 'from_name': 'Zulip Account Security', + 'from_address': FromAddress.NOREPLY, + 'context': context} + queue_json_publish("email_senders", email_dict)