mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-02 17:31:14 -05:00
Use the template version at the time the notification is created or at the time the job is created.
Update notifications/sms|email endpoint to send the template version to the queue. Update the process_job celery talk to send the template version to the queue. When the send_sms|send_email task runs it will get the template by id and version. Created a data migration script to add the template_vesion column for jobs and notifications. The existing jobs and notifications are given the template_version of the current template. There is a chance this is the wrong template version, but deemed okay since the application is not live. Create unit test for the dao_get_template_versions method. Rename /template/<id>/version to /template/<id>/versions which returns all versions for that template id and service id.
This commit is contained in:
@@ -285,6 +285,7 @@ def send_email(service_id, notification_id, from_address, encrypted_notification
|
||||
notification_db_object = Notification(
|
||||
id=notification_id,
|
||||
template_id=notification['template'],
|
||||
template_version=notification['template_version'],
|
||||
to=notification['to'],
|
||||
service_id=service_id,
|
||||
job_id=notification.get('job', None),
|
||||
@@ -301,7 +302,7 @@ def send_email(service_id, notification_id, from_address, encrypted_notification
|
||||
|
||||
try:
|
||||
template = Template(
|
||||
dao_get_template_by_id(notification['template']).__dict__,
|
||||
dao_get_template_by_id(notification['template'], notification['template_version']).__dict__,
|
||||
values=notification.get('personalisation', {})
|
||||
)
|
||||
reference = provider.send_email(
|
||||
@@ -315,8 +316,8 @@ def send_email(service_id, notification_id, from_address, encrypted_notification
|
||||
except EmailClientException as e:
|
||||
current_app.logger.exception(e)
|
||||
notification_db_object.status = 'failed'
|
||||
dao_update_notification(notification_db_object)
|
||||
|
||||
dao_update_notification(notification_db_object)
|
||||
current_app.logger.info(
|
||||
"Email {} created at {} sent at {}".format(notification_id, created_at, sent_at)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user