mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 07:21:13 -05:00
merge from main and reformat
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import random
|
||||
from datetime import datetime
|
||||
from urllib import parse
|
||||
|
||||
@@ -14,9 +13,7 @@ from app import create_uuid, db, notification_provider_clients
|
||||
from app.celery.test_key_tasks import send_email_response, send_sms_response
|
||||
from app.dao.email_branding_dao import dao_get_email_branding_by_id
|
||||
from app.dao.notifications_dao import dao_update_notification
|
||||
from app.dao.provider_details_dao import (
|
||||
get_provider_details_by_notification_type,
|
||||
)
|
||||
from app.dao.provider_details_dao import get_provider_details_by_notification_type
|
||||
from app.exceptions import NotificationTechnicalFailureException
|
||||
from app.models import (
|
||||
BRANDING_BOTH,
|
||||
@@ -161,13 +158,8 @@ def provider_to_use(notification_type, international=True):
|
||||
)
|
||||
raise Exception("No active {} providers".format(notification_type))
|
||||
|
||||
if len(active_providers) == 1:
|
||||
chosen_provider = active_providers[0]
|
||||
else:
|
||||
weights = [p.priority for p in active_providers]
|
||||
chosen_provider = random.choices(active_providers, weights=weights)[
|
||||
0
|
||||
] # nosec B311 - not sec/crypto related
|
||||
# we only have sns
|
||||
chosen_provider = active_providers[0]
|
||||
|
||||
return notification_provider_clients.get_client_by_name_and_type(
|
||||
chosen_provider.identifier, notification_type
|
||||
|
||||
Reference in New Issue
Block a user