mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 15:46:07 -05:00
This massive set of changes uses the new queue names object throughout the app and tests.
Lots of changes, all changing the line of code that puts things into queues, and the code that tests that.
This commit is contained in:
@@ -13,7 +13,7 @@ from app.celery.tasks import update_letter_notifications_statuses
|
||||
from app.v2.errors import register_errors
|
||||
from app.notifications.utils import autoconfirm_subscription
|
||||
from app.schema_validation import validate
|
||||
|
||||
from app.config import QueueNames
|
||||
|
||||
letter_callback_blueprint = Blueprint('notifications_letter_callback', __name__)
|
||||
register_errors(letter_callback_blueprint)
|
||||
@@ -54,7 +54,7 @@ def process_letter_response():
|
||||
filename = message['Records'][0]['s3']['object']['key']
|
||||
current_app.logger.info('Received file from DVLA: {}'.format(filename))
|
||||
current_app.logger.info('DVLA callback: Calling task to update letter notifications')
|
||||
update_letter_notifications_statuses.apply_async([filename], queue='notify')
|
||||
update_letter_notifications_statuses.apply_async([filename], queue=QueueNames.NOTIFY)
|
||||
|
||||
return jsonify(
|
||||
result="success", message="DVLA callback succeeded"
|
||||
|
||||
@@ -10,6 +10,8 @@ from notifications_utils.recipients import (
|
||||
from app import redis_store
|
||||
from app.celery import provider_tasks
|
||||
from notifications_utils.clients import redis
|
||||
|
||||
from app.config import QueueNames
|
||||
from app.dao.notifications_dao import dao_create_notification, dao_delete_notifications_and_history_by_id
|
||||
from app.models import SMS_TYPE, Notification, KEY_TYPE_TEST, EMAIL_TYPE
|
||||
from app.v2.errors import BadRequestError, SendNotificationToQueueError
|
||||
@@ -90,12 +92,9 @@ def persist_notification(
|
||||
|
||||
def send_notification_to_queue(notification, research_mode, queue=None):
|
||||
if research_mode or notification.key_type == KEY_TYPE_TEST:
|
||||
queue = 'research-mode'
|
||||
queue = QueueNames.RESEARCH_MODE
|
||||
elif not queue:
|
||||
if notification.notification_type == SMS_TYPE:
|
||||
queue = 'send-sms'
|
||||
if notification.notification_type == EMAIL_TYPE:
|
||||
queue = 'send-email'
|
||||
queue = QueueNames.SEND
|
||||
|
||||
if notification.notification_type == SMS_TYPE:
|
||||
deliver_task = provider_tasks.deliver_sms
|
||||
|
||||
@@ -6,6 +6,7 @@ from flask import (
|
||||
)
|
||||
|
||||
from app import api_user, authenticated_service
|
||||
from app.config import QueueNames
|
||||
from app.dao import (
|
||||
templates_dao,
|
||||
notifications_dao
|
||||
@@ -134,7 +135,7 @@ def send_notification(notification_type):
|
||||
key_type=api_user.key_type,
|
||||
simulated=simulated)
|
||||
if not simulated:
|
||||
queue_name = 'priority' if template.process_type == PRIORITY else None
|
||||
queue_name = QueueNames.PRIORITY if template.process_type == PRIORITY else None
|
||||
send_notification_to_queue(notification=notification_model,
|
||||
research_mode=authenticated_service.research_mode,
|
||||
queue=queue_name)
|
||||
|
||||
Reference in New Issue
Block a user