mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-30 14:31:57 -05:00
send to send-sms-tasks and send-email-tasks instead of send-tasks
This commit is contained in:
@@ -182,7 +182,7 @@ def send_sms(self,
|
||||
|
||||
provider_tasks.deliver_sms.apply_async(
|
||||
[str(saved_notification.id)],
|
||||
queue=QueueNames.SEND_COMBINED if not service.research_mode else QueueNames.RESEARCH_MODE
|
||||
queue=QueueNames.SEND_SMS if not service.research_mode else QueueNames.RESEARCH_MODE
|
||||
)
|
||||
|
||||
current_app.logger.info(
|
||||
@@ -227,7 +227,7 @@ def send_email(self,
|
||||
|
||||
provider_tasks.deliver_email.apply_async(
|
||||
[str(saved_notification.id)],
|
||||
queue=QueueNames.SEND_COMBINED if not service.research_mode else QueueNames.RESEARCH_MODE
|
||||
queue=QueueNames.SEND_EMAIL if not service.research_mode else QueueNames.RESEARCH_MODE
|
||||
)
|
||||
|
||||
current_app.logger.info("Email {} created at {}".format(saved_notification.id, created_at))
|
||||
|
||||
@@ -24,16 +24,20 @@ def send_notification_to_provider(notification_id):
|
||||
send_response(
|
||||
send_to_providers.send_email_to_provider,
|
||||
provider_tasks.deliver_email,
|
||||
notification)
|
||||
notification,
|
||||
QueueNames.SEND_EMAIL
|
||||
)
|
||||
else:
|
||||
send_response(
|
||||
send_to_providers.send_sms_to_provider,
|
||||
provider_tasks.deliver_sms,
|
||||
notification)
|
||||
notification,
|
||||
QueueNames.SEND_SMS
|
||||
)
|
||||
return jsonify({}), 204
|
||||
|
||||
|
||||
def send_response(send_call, task_call, notification):
|
||||
def send_response(send_call, task_call, notification, queue):
|
||||
try:
|
||||
send_call(notification)
|
||||
except Exception as e:
|
||||
@@ -42,4 +46,4 @@ def send_response(send_call, task_call, notification):
|
||||
notification.id,
|
||||
notification.notification_type),
|
||||
e)
|
||||
task_call.apply_async((str(notification.id)), queue=QueueNames.SEND_COMBINED)
|
||||
task_call.apply_async((str(notification.id)), queue=queue)
|
||||
|
||||
@@ -100,12 +100,14 @@ def persist_notification(
|
||||
def send_notification_to_queue(notification, research_mode, queue=None):
|
||||
if research_mode or notification.key_type == KEY_TYPE_TEST:
|
||||
queue = QueueNames.RESEARCH_MODE
|
||||
elif not queue:
|
||||
queue = QueueNames.SEND_COMBINED
|
||||
|
||||
if notification.notification_type == SMS_TYPE:
|
||||
if not queue:
|
||||
queue = QueueNames.SEND_SMS
|
||||
deliver_task = provider_tasks.deliver_sms
|
||||
if notification.notification_type == EMAIL_TYPE:
|
||||
if not queue:
|
||||
queue = QueueNames.SEND_EMAIL
|
||||
deliver_task = provider_tasks.deliver_email
|
||||
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user