Remove placeholder sms callback comments

This commit is contained in:
Ryan Ahearn
2023-01-03 10:23:14 -05:00
parent d70e1b125a
commit 7878316790
5 changed files with 0 additions and 412 deletions

View File

@@ -150,9 +150,6 @@ def register_blueprint(application):
from app.notifications.notifications_ses_callback import (
ses_callback_blueprint,
)
from app.notifications.notifications_sms_callback import (
sms_callback_blueprint,
)
from app.notifications.receive_notifications import (
receive_notifications_blueprint,
)
@@ -201,11 +198,6 @@ def register_blueprint(application):
ses_callback_blueprint.before_request(requires_no_auth)
application.register_blueprint(ses_callback_blueprint)
# delivery receipts
# TODO: make sure research mode can still trigger sms callbacks, then re-enable this
sms_callback_blueprint.before_request(requires_no_auth)
application.register_blueprint(sms_callback_blueprint)
# inbound sms
receive_notifications_blueprint.before_request(requires_no_auth)
application.register_blueprint(receive_notifications_blueprint)

View File

@@ -1,80 +0,0 @@
from app import notify_celery
sms_response_mapper = {
# 'SNS': get_sns_responses,
}
# this is used by notifications_sms_callback and needs to be heavily changed for SNS
# leaving for now as an example of what MMG did and what we may want to replicate in the eventual
# SNS method
@notify_celery.task(bind=True, name="process-sms-client-response", max_retries=5, default_retry_delay=300)
def process_sms_client_response(self, status, provider_reference, client_name, detailed_status_code=None):
raise Exception("process_sms_client_response not implemented")
# # validate reference
# try:
# uuid.UUID(provider_reference, version=4)
# except ValueError as e:
# current_app.logger.exception(f'{client_name} callback with invalid reference {provider_reference}')
# raise e
# response_parser = sms_response_mapper[client_name]
# # validate status
# try:
# notification_status, detailed_status = response_parser(status, detailed_status_code)
# current_app.logger.info(
# f'{client_name} callback returned status of {notification_status}'
# f'({status}): {detailed_status}({detailed_status_code}) for reference: {provider_reference}'
# )
# except KeyError:
# _process_for_status(
# notification_status='technical-failure',
# client_name=client_name,
# provider_reference=provider_reference
# )
# raise ClientException(f'{client_name} callback failed: status {status} not found.')
# _process_for_status(
# notification_status=notification_status,
# client_name=client_name,
# provider_reference=provider_reference,
# detailed_status_code=detailed_status_code
# )
# def _process_for_status(notification_status, client_name, provider_reference, detailed_status_code=None):
# # record stats
# notification = notifications_dao.update_notification_status_by_id(
# notification_id=provider_reference,
# status=notification_status,
# sent_by=client_name.lower(),
# detailed_status_code=detailed_status_code
# )
# if not notification:
# return
# statsd_client.incr('callback.{}.{}'.format(client_name.lower(), notification_status))
# if notification.sent_at:
# statsd_client.timing_with_dates(
# f'callback.{client_name.lower()}.{notification_status}.elapsed-time',
# datetime.utcnow(),
# notification.sent_at
# )
# if notification.billable_units == 0:
# service = notification.service
# template_model = dao_get_template_by_id(notification.template_id, notification.template_version)
# template = SMSMessageTemplate(
# template_model.__dict__,
# values=notification.personalisation,
# prefix=service.name,
# show_prefix=service.prefix_sms,
# )
# notification.billable_units = template.fragment_count
# notifications_dao.dao_update_notification(notification)
# if notification_status != NOTIFICATION_PENDING:
# check_and_queue_callback_task(notification)

View File

@@ -1,42 +0,0 @@
from flask import Blueprint
from app.errors import register_errors
sms_callback_blueprint = Blueprint("sms_callback", __name__, url_prefix="/notifications/sms")
register_errors(sms_callback_blueprint)
# TODO SNS SMS delivery receipts delivered here
# This file should likely be deleted, since SNS does not use callback https calls
# Leaving for now to have an example of what jobs MMG did that we may want to replicate in the
# eventual SNS method.
# @sms_callback_blueprint.route('/mmg', methods=['POST'])
# def process_mmg_response():
# client_name = 'MMG'
# data = json.loads(request.data)
# errors = validate_callback_data(data=data,
# fields=['status', 'CID'],
# client_name=client_name)
# if errors:
# raise InvalidRequest(errors, status_code=400)
# status = str(data.get('status'))
# detailed_status_code = str(data.get('substatus'))
# provider_reference = data.get('CID')
# process_sms_client_response.apply_async(
# [status, provider_reference, client_name, detailed_status_code],
# queue=QueueNames.SMS_CALLBACKS,
# )
# return jsonify(result='success'), 200
def validate_callback_data(data, fields, client_name):
errors = []
for f in fields:
if not str(data.get(f, '')):
error = "{} callback failed: {} missing".format(client_name, f)
errors.append(error)
return errors if len(errors) > 0 else None