mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-05 10:42:41 -05:00
Build the from address in the task instead of the rest call.
This commit is contained in:
@@ -343,6 +343,9 @@ def send_email(service_id, notification_id, from_address, encrypted_notification
|
|||||||
(provider.get_name(), str(reference), notification['to']), queue='research-mode'
|
(provider.get_name(), str(reference), notification['to']), queue='research-mode'
|
||||||
)
|
)
|
||||||
else:
|
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
|
||||||
reference = provider.send_email(
|
reference = provider.send_email(
|
||||||
from_address,
|
from_address,
|
||||||
notification['to'],
|
notification['to'],
|
||||||
|
|||||||
@@ -387,7 +387,7 @@ def send_notification(notification_type):
|
|||||||
send_email.apply_async((
|
send_email.apply_async((
|
||||||
service_id,
|
service_id,
|
||||||
notification_id,
|
notification_id,
|
||||||
'"{}" <{}@{}>'.format(service.name, service.email_from, current_app.config['NOTIFY_EMAIL_DOMAIN']),
|
'',
|
||||||
encryption.encrypt(notification),
|
encryption.encrypt(notification),
|
||||||
datetime.utcnow().strftime(DATETIME_FORMAT)
|
datetime.utcnow().strftime(DATETIME_FORMAT)
|
||||||
), queue='email')
|
), queue='email')
|
||||||
|
|||||||
@@ -946,7 +946,7 @@ def test_should_allow_valid_email_notification(notify_api, sample_email_template
|
|||||||
app.celery.tasks.send_email.apply_async.assert_called_once_with(
|
app.celery.tasks.send_email.apply_async.assert_called_once_with(
|
||||||
(str(sample_email_template.service_id),
|
(str(sample_email_template.service_id),
|
||||||
notification_id,
|
notification_id,
|
||||||
"\"Sample service\" <sample.service@test.notify.com>",
|
"",
|
||||||
"something_encrypted",
|
"something_encrypted",
|
||||||
"2016-01-01T11:09:00.061258"),
|
"2016-01-01T11:09:00.061258"),
|
||||||
queue="email"
|
queue="email"
|
||||||
|
|||||||
Reference in New Issue
Block a user