Fix the send_sms and send_email code to send the notification id that has been persisted.

This commit is contained in:
Rebecca Law
2016-11-11 16:00:31 +00:00
parent c45d1f63a7
commit 4fe8d700ae
3 changed files with 56 additions and 58 deletions

View File

@@ -130,26 +130,26 @@ def send_sms(self,
return
try:
persist_notification(template_id=notification['template'],
template_version=notification['template_version'],
recipient=notification['to'],
service_id=service.id,
personalisation=notification.get('personalisation'),
notification_type=SMS_TYPE,
api_key_id=api_key_id,
key_type=key_type,
created_at=created_at,
job_id=notification.get('job', None),
job_row_number=notification.get('row_number', None),
)
saved_notification = persist_notification(template_id=notification['template'],
template_version=notification['template_version'],
recipient=notification['to'],
service_id=service.id,
personalisation=notification.get('personalisation'),
notification_type=SMS_TYPE,
api_key_id=api_key_id,
key_type=key_type,
created_at=created_at,
job_id=notification.get('job', None),
job_row_number=notification.get('row_number', None),
)
provider_tasks.deliver_sms.apply_async(
[notification_id],
[saved_notification.id],
queue='send-sms' if not service.research_mode else 'research-mode'
)
current_app.logger.info(
"SMS {} created at {} for job {}".format(notification_id, created_at, notification.get('job', None))
"SMS {} created at {} for job {}".format(saved_notification.id, created_at, notification.get('job', None))
)
except SQLAlchemyError as e:
@@ -179,7 +179,7 @@ def send_email(self, service_id,
return
try:
persist_notification(
saved_notification = persist_notification(
template_id=notification['template'],
template_version=notification['template_version'],
recipient=notification['to'],
@@ -195,7 +195,7 @@ def send_email(self, service_id,
)
provider_tasks.deliver_email.apply_async(
[notification_id],
[saved_notification.id],
queue='send-email' if not service.research_mode else 'research-mode'
)

View File

@@ -77,7 +77,7 @@ def send_notification_to_queue(notification, research_mode):
[str(notification.id)],
queue='send-email' if not research_mode else 'research-mode'
)
except Exception as e:
except Exception:
current_app.logger.exception("Failed to send to SQS exception")
dao_delete_notifications_and_history_by_id(notification.id)
raise