Merge pull request #412 from alphagov/use-notify-to-send-email-verification-links

Safely change task signature - first deploy
This commit is contained in:
Rebecca Law
2016-06-14 15:42:59 +01:00
committed by GitHub
4 changed files with 17 additions and 31 deletions

View File

@@ -183,7 +183,6 @@ def process_job(job_id):
send_email.apply_async((
str(job.service_id),
create_uuid(),
'',
encrypted,
datetime.utcnow().strftime(DATETIME_FORMAT)),
{'reply_to_addresses': service.reply_to_email_address},
@@ -289,7 +288,13 @@ 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):
def send_email_v1(service_id, notification_id, from_address,
encrypted_notification, created_at, reply_to_addresses=None):
send_email(service_id, notification_id, encrypted_notification, created_at, reply_to_addresses=None)
@notify_celery.task(name="send-email-v2")
def send_email(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'],

View File

@@ -28,7 +28,6 @@ from app.schemas import (
from app.celery.tasks import (
send_sms,
email_reset_password,
email_registration_verification,
send_email)
from app.errors import register_errors
@@ -170,7 +169,6 @@ def send_user_email_verification(user_id):
send_email.apply_async((
current_app.config['NOTIFY_SERVICE_ID'],
str(uuid.uuid4()),
'',
encryption.encrypt(message),
datetime.utcnow().strftime(DATETIME_FORMAT)
), queue='email-registration-verification')