Localize notification_utils to the API

This changeset pulls in all of the notification_utils code directly into the API and removes it as an external dependency.  We are doing this to cut down on operational maintenance of the project and will begin removing parts of it no longer needed for the API.

Signed-off-by: Carlo Costino <carlo.costino@gsa.gov>
This commit is contained in:
Carlo Costino
2024-05-16 10:17:45 -04:00
parent 4cdf8b2cb2
commit 99edc88197
129 changed files with 49913 additions and 263 deletions

View File

@@ -2,12 +2,6 @@ import uuid
from datetime import datetime
from flask import current_app
from notifications_utils.recipients import (
format_email_address,
get_international_phone_info,
validate_and_format_phone_number,
)
from notifications_utils.template import PlainTextEmailTemplate, SMSMessageTemplate
from app import redis_store
from app.celery import provider_tasks
@@ -19,6 +13,12 @@ from app.dao.notifications_dao import (
from app.enums import KeyType, NotificationStatus, NotificationType
from app.models import Notification
from app.v2.errors import BadRequestError
from notifications_utils.recipients import (
format_email_address,
get_international_phone_info,
validate_and_format_phone_number,
)
from notifications_utils.template import PlainTextEmailTemplate, SMSMessageTemplate
def create_content_for_notification(template, personalisation):

View File

@@ -1,5 +1,4 @@
from flask import Blueprint, current_app, json, jsonify, request
from notifications_utils.recipients import try_validate_and_format_phone_number
from app.celery import tasks
from app.config import QueueNames
@@ -9,6 +8,7 @@ from app.enums import ServicePermissionType
from app.errors import InvalidRequest, register_errors
from app.models import InboundSms
from app.notifications.sns_handlers import sns_notification_handler
from notifications_utils.recipients import try_validate_and_format_phone_number
receive_notifications_blueprint = Blueprint("receive_notifications", __name__)
register_errors(receive_notifications_blueprint)

View File

@@ -1,5 +1,4 @@
from flask import Blueprint, current_app, jsonify, request
from notifications_utils import SMS_CHAR_COUNT_LIMIT
from app import api_user, authenticated_service
from app.aws.s3 import get_personalisation_from_s3, get_phone_number_from_s3
@@ -26,6 +25,7 @@ from app.schemas import (
)
from app.service.utils import service_allowed_to_send_to
from app.utils import get_public_notify_type_text, pagination_links
from notifications_utils import SMS_CHAR_COUNT_LIMIT
notifications = Blueprint("notifications", __name__)

View File

@@ -1,14 +1,4 @@
from flask import current_app
from notifications_utils import SMS_CHAR_COUNT_LIMIT
from notifications_utils.clients.redis import (
rate_limit_cache_key,
total_limit_cache_key,
)
from notifications_utils.recipients import (
get_international_phone_info,
validate_and_format_email_address,
validate_and_format_phone_number,
)
from sqlalchemy.orm.exc import NoResultFound
from app import redis_store
@@ -22,6 +12,16 @@ from app.serialised_models import SerialisedTemplate
from app.service.utils import service_allowed_to_send_to
from app.utils import get_public_notify_type_text
from app.v2.errors import BadRequestError, RateLimitError, TotalRequestsError
from notifications_utils import SMS_CHAR_COUNT_LIMIT
from notifications_utils.clients.redis import (
rate_limit_cache_key,
total_limit_cache_key,
)
from notifications_utils.recipients import (
get_international_phone_info,
validate_and_format_email_address,
validate_and_format_phone_number,
)
def check_service_over_api_rate_limit(service, api_key):