mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 15:46:07 -05:00
Add optional queue param to send_notification_to_queue
We want to use this function for sending internal notifications to a different queue.
This commit is contained in:
@@ -70,19 +70,22 @@ def persist_notification(template_id,
|
||||
return notification
|
||||
|
||||
|
||||
def send_notification_to_queue(notification, research_mode):
|
||||
try:
|
||||
research_mode = research_mode or notification.key_type == KEY_TYPE_TEST
|
||||
def send_notification_to_queue(notification, research_mode, queue=None):
|
||||
if research_mode or notification.key_type == KEY_TYPE_TEST:
|
||||
queue = 'research-mode'
|
||||
elif not queue:
|
||||
if notification.notification_type == SMS_TYPE:
|
||||
provider_tasks.deliver_sms.apply_async(
|
||||
[str(notification.id)],
|
||||
queue='send-sms' if not research_mode else 'research-mode'
|
||||
)
|
||||
queue = 'send-sms'
|
||||
if notification.notification_type == EMAIL_TYPE:
|
||||
provider_tasks.deliver_email.apply_async(
|
||||
[str(notification.id)],
|
||||
queue='send-email' if not research_mode else 'research-mode'
|
||||
)
|
||||
queue = 'send-email'
|
||||
|
||||
if notification.notification_type == SMS_TYPE:
|
||||
deliver_task = provider_tasks.deliver_sms
|
||||
if notification.notification_type == EMAIL_TYPE:
|
||||
deliver_task = provider_tasks.deliver_email
|
||||
|
||||
try:
|
||||
deliver_task.apply_async([str(notification.id)], queue=queue)
|
||||
except Exception as e:
|
||||
current_app.logger.exception(e)
|
||||
dao_delete_notifications_and_history_by_id(notification.id)
|
||||
|
||||
Reference in New Issue
Block a user