mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-22 00:11:16 -05:00
move available provider logic to the service model
make sure it's in an accessible place so we don't end up duplicating our work
This commit is contained in:
@@ -17,14 +17,11 @@ def send_broadcast_event(broadcast_event_id):
|
||||
return
|
||||
|
||||
broadcast_event = dao_get_broadcast_event_by_id(broadcast_event_id)
|
||||
for provider in current_app.config['ENABLED_CBCS']:
|
||||
if broadcast_event.service.allowed_broadcast_provider in {None, provider}:
|
||||
# There may be future checks here to decide whether to send to each provider based on platform admin level
|
||||
# settings
|
||||
send_broadcast_provider_message.apply_async(
|
||||
kwargs={'broadcast_event_id': broadcast_event_id, 'provider': provider},
|
||||
queue=QueueNames.NOTIFY
|
||||
)
|
||||
for provider in broadcast_event.service.get_available_broadcast_providers():
|
||||
send_broadcast_provider_message.apply_async(
|
||||
kwargs={'broadcast_event_id': broadcast_event_id, 'provider': provider},
|
||||
queue=QueueNames.NOTIFY
|
||||
)
|
||||
|
||||
|
||||
@notify_celery.task(name="send-broadcast-provider-message")
|
||||
@@ -80,19 +77,6 @@ def send_broadcast_provider_message(broadcast_event_id, provider):
|
||||
|
||||
@notify_celery.task(name='trigger-link-test')
|
||||
def trigger_link_test(provider):
|
||||
"""
|
||||
Currently we only have one hardcoded CBC Proxy, which corresponds to one
|
||||
CBC, and so currently we do not specify the CBC Proxy name
|
||||
|
||||
In future we will have multiple CBC proxies, each proxy corresponding to
|
||||
one MNO's CBC
|
||||
|
||||
This task should invoke other tasks which do the actual link tests, eg:
|
||||
for cbc_name in app.config.ENABLED_CBCS:
|
||||
send_link_test_for_cbc(cbc_name)
|
||||
|
||||
Alternatively this task could be configured to be a Celery group
|
||||
"""
|
||||
identifier = str(uuid.uuid4())
|
||||
message = f"Sending a link test to CBC proxy for provider {provider} with ID {identifier}"
|
||||
current_app.logger.info(message)
|
||||
|
||||
Reference in New Issue
Block a user