From e77137c2f96fda04b904dd3b07d3b78d43ef6051 Mon Sep 17 00:00:00 2001 From: Sofiya Semenova Date: Fri, 17 Nov 2017 15:32:56 -0500 Subject: [PATCH] Don't get the site object unless the message is going to be sent --- lms/djangoapps/discussion/tasks.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lms/djangoapps/discussion/tasks.py b/lms/djangoapps/discussion/tasks.py index 5c5fe4fcfa..ed360dc3e7 100644 --- a/lms/djangoapps/discussion/tasks.py +++ b/lms/djangoapps/discussion/tasks.py @@ -3,7 +3,6 @@ Defines asynchronous celery task for sending email notification (through edx-ace pertaining to new discussion forum comments. """ import logging -from urllib import urlencode from urlparse import urljoin from celery import task @@ -41,8 +40,9 @@ class ResponseNotification(MessageType): @task(base=LoggedTask, routing_key=ROUTING_KEY) def send_ace_message(context): context['course_id'] = CourseKey.from_string(context['course_id']) - context['site'] = Site.objects.get(id=context['site_id']) + if _should_send_message(context): + context['site'] = Site.objects.get(id=context['site_id']) thread_author = User.objects.get(id=context['thread_author_id']) middleware_classes = [ CurrentRequestUserMiddleware,