mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-30 14:31:57 -05:00
Fix the send_sms and send_email code to send the notification id that has been persisted.
This commit is contained in:
@@ -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'
|
||||
)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user