mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-24 00:06:16 -04:00
Tasks now use the new builder method to construct the DB object.
This commit is contained in:
@@ -133,8 +133,11 @@ def send_sms(self,
|
|||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
_save_notification(created_at, notification, notification_id, service_id, SMS_TYPE, api_key_id, key_type)
|
dao_create_notification(
|
||||||
|
Notification.from_api_request(
|
||||||
|
created_at, notification, notification_id, service.id, SMS_TYPE, api_key_id, key_type
|
||||||
|
)
|
||||||
|
)
|
||||||
send_sms_to_provider.apply_async((service_id, notification_id), queue='send-sms')
|
send_sms_to_provider.apply_async((service_id, notification_id), queue='send-sms')
|
||||||
|
|
||||||
current_app.logger.info(
|
current_app.logger.info(
|
||||||
@@ -168,7 +171,11 @@ def send_email(self, service_id,
|
|||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
_save_notification(created_at, notification, notification_id, service_id, EMAIL_TYPE, api_key_id, key_type)
|
dao_create_notification(
|
||||||
|
Notification.from_api_request(
|
||||||
|
created_at, notification, notification_id, service.id, EMAIL_TYPE, api_key_id, key_type
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
send_email_to_provider.apply_async((service_id, notification_id), queue='send-email')
|
send_email_to_provider.apply_async((service_id, notification_id), queue='send-email')
|
||||||
|
|
||||||
@@ -184,25 +191,6 @@ def send_email(self, service_id,
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def _save_notification(created_at, notification, notification_id, service_id, notification_type, api_key_id, key_type):
|
|
||||||
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),
|
|
||||||
job_row_number=notification.get('row_number', None),
|
|
||||||
status='created',
|
|
||||||
created_at=datetime.strptime(created_at, DATETIME_FORMAT),
|
|
||||||
personalisation=notification.get('personalisation'),
|
|
||||||
notification_type=notification_type,
|
|
||||||
api_key_id=api_key_id,
|
|
||||||
key_type=key_type
|
|
||||||
)
|
|
||||||
dao_create_notification(notification_db_object)
|
|
||||||
|
|
||||||
|
|
||||||
def service_allowed_to_send_to(recipient, service):
|
def service_allowed_to_send_to(recipient, service):
|
||||||
if not service.restricted:
|
if not service.restricted:
|
||||||
return True
|
return True
|
||||||
|
|||||||
Reference in New Issue
Block a user