Create a new task called send_email_v2 so that I can get rid of the from_address in the signature.

This is done to make sure we do not lose any messages in the queue during deployment.
This commit is contained in:
Rebecca Law
2016-06-13 15:31:45 +01:00
parent 5fc14940f3
commit cd2627e5ed
5 changed files with 20 additions and 18 deletions

View File

@@ -180,7 +180,7 @@ def process_job(job_id):
)
if template.template_type == 'email':
send_email.apply_async((
send_email_v2.apply_async((
str(job.service_id),
create_uuid(),
'',
@@ -290,6 +290,11 @@ def send_sms(service_id, notification_id, encrypted_notification, created_at):
@notify_celery.task(name="send-email")
def send_email(service_id, notification_id, from_address, encrypted_notification, created_at, reply_to_addresses=None):
send_email_v2(service_id, notification_id, encrypted_notification, created_at, reply_to_addresses=None)
@notify_celery.task(name="send-email-v2")
def send_email_v2(service_id, notification_id, encrypted_notification, created_at, reply_to_addresses=None):
task_start = monotonic()
notification = encryption.decrypt(encrypted_notification)
service = dao_fetch_service_by_id(service_id)
@@ -337,9 +342,8 @@ def send_email(service_id, notification_id, from_address, encrypted_notification
(provider.get_name(), str(reference), notification['to']), queue='research-mode'
)
else:
# First step setting the from_address here rather than the method creating the task
from_address = '"{}" <{}@{}>'.format(service.name, service.email_from, current_app.config[
'NOTIFY_EMAIL_DOMAIN']) if from_address == "" else from_address
from_address = '"{}" <{}@{}>'.format(service.name, service.email_from,
current_app.config['NOTIFY_EMAIL_DOMAIN'])
reference = provider.send_email(
from_address,
notification['to'],