mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
latest
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,6 +4,7 @@ queues.csv
|
|||||||
__pycache__/
|
__pycache__/
|
||||||
*.py[cod]
|
*.py[cod]
|
||||||
|
|
||||||
|
.venv/
|
||||||
venv/
|
venv/
|
||||||
venv-freeze/
|
venv-freeze/
|
||||||
|
|
||||||
|
|||||||
5
Makefile
5
Makefile
@@ -71,6 +71,7 @@ test: ## Run tests
|
|||||||
freeze-requirements: ## Pin all requirements including sub dependencies into requirements.txt
|
freeze-requirements: ## Pin all requirements including sub dependencies into requirements.txt
|
||||||
pip install --upgrade pip-tools
|
pip install --upgrade pip-tools
|
||||||
pip-compile requirements.in
|
pip-compile requirements.in
|
||||||
|
pip install -r requirements.txt
|
||||||
|
|
||||||
.PHONY: audit
|
.PHONY: audit
|
||||||
audit:
|
audit:
|
||||||
@@ -137,11 +138,11 @@ cf-deploy-api-db-migration:
|
|||||||
cf push notifications-api --no-route -f ${CF_MANIFEST_PATH}
|
cf push notifications-api --no-route -f ${CF_MANIFEST_PATH}
|
||||||
rm ${CF_MANIFEST_PATH}
|
rm ${CF_MANIFEST_PATH}
|
||||||
|
|
||||||
cf run-task notifications-api --command="flask db upgrade" --name api_db_migration
|
cf run-task notify-api-alt --command="flask db upgrade" --name api_db_migration
|
||||||
|
|
||||||
.PHONY: cf-check-api-db-migration-task
|
.PHONY: cf-check-api-db-migration-task
|
||||||
cf-check-api-db-migration-task: ## Get the status for the last notifications-api task
|
cf-check-api-db-migration-task: ## Get the status for the last notifications-api task
|
||||||
@cf curl /v3/apps/`cf app --guid notifications-api`/tasks?order_by=-created_at | jq -r ".resources[0].state"
|
@cf curl /v3/apps/`cf app --guid notify-api-alt`/tasks?order_by=-created_at | jq -r ".resources[0].state"
|
||||||
|
|
||||||
.PHONY: cf-rollback
|
.PHONY: cf-rollback
|
||||||
cf-rollback: ## Rollbacks the app to the previous release
|
cf-rollback: ## Rollbacks the app to the previous release
|
||||||
|
|||||||
@@ -23,6 +23,62 @@ INBOUND_SMS_COUNTER = Counter(
|
|||||||
['provider']
|
['provider']
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@receive_notifications_blueprint.route('/notifications/sms/receive/sns', methods=['POST'])
|
||||||
|
def receive_sns_sms():
|
||||||
|
"""
|
||||||
|
{
|
||||||
|
"originationNumber":"+14255550182",
|
||||||
|
"destinationNumber":"+12125550101",
|
||||||
|
"messageKeyword":"JOIN", # this is optional
|
||||||
|
"messageBody":"EXAMPLE",
|
||||||
|
"inboundMessageId":"cae173d2-66b9-564c-8309-21f858e9fb84",
|
||||||
|
"previousPublishedMessageId":"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
post_data = request.get_json()
|
||||||
|
|
||||||
|
# validate sns from common module, WILL ALSO NEED TO AUTO-SUBSCRIBE... raise errors appropriately
|
||||||
|
|
||||||
|
# TODO modify this for AWS SNS
|
||||||
|
inbound_number = strip_leading_forty_four(post_data['Number'])
|
||||||
|
|
||||||
|
service = fetch_potential_service(inbound_number, 'sns')
|
||||||
|
if not service:
|
||||||
|
# since this is an issue with our service <-> number mapping, or no inbound_sms service permission
|
||||||
|
# we should still tell SNS that we received it successfully
|
||||||
|
current_app.logger.warning(f"Mapping between service id and inbound number is broken, or service does not have permission to receive inbound sms")
|
||||||
|
return jsonify({
|
||||||
|
"status": "ok"
|
||||||
|
}), 200
|
||||||
|
|
||||||
|
INBOUND_SMS_COUNTER.labels("sns").inc()
|
||||||
|
|
||||||
|
content = format_mmg_message(post_data["Message"])
|
||||||
|
from_number = post_data['MSISDN']
|
||||||
|
provider_ref = post_data["ID"]
|
||||||
|
date_received = post_data.get('DateRecieved')
|
||||||
|
provider_name = "sns"
|
||||||
|
|
||||||
|
inbound_payload = {}
|
||||||
|
|
||||||
|
# TODO fill inbound_payload and spread like create_inbound_sms_object(service, **inbound_payload)
|
||||||
|
inbound = create_inbound_sms_object(service,
|
||||||
|
content=format_mmg_message(post_data["Message"]),
|
||||||
|
from_number=from_number,
|
||||||
|
provider_ref=provider_ref,
|
||||||
|
date_received=date_received,
|
||||||
|
provider_name=provider_name)
|
||||||
|
|
||||||
|
# TODO ensure inbound sms callback endpoints are accessible and functioning for notify api users
|
||||||
|
# tasks.send_inbound_sms_to_service.apply_async([str(inbound.id), str(service.id)], queue=QueueNames.NOTIFY)
|
||||||
|
|
||||||
|
current_app.logger.debug(
|
||||||
|
'{} received inbound SMS with reference {} from SNS'.format(service.id, inbound.provider_reference))
|
||||||
|
|
||||||
|
return jsonify({
|
||||||
|
"status": "ok"
|
||||||
|
}), 200
|
||||||
|
|
||||||
@receive_notifications_blueprint.route('/notifications/sms/receive/mmg', methods=['POST'])
|
@receive_notifications_blueprint.route('/notifications/sms/receive/mmg', methods=['POST'])
|
||||||
def receive_mmg_sms():
|
def receive_mmg_sms():
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ celery[sqs]==5.2.6
|
|||||||
Flask-Bcrypt==1.0.1
|
Flask-Bcrypt==1.0.1
|
||||||
flask-marshmallow==0.14.0
|
flask-marshmallow==0.14.0
|
||||||
Flask-Migrate==3.1.0
|
Flask-Migrate==3.1.0
|
||||||
Flask-SQLAlchemy==2.5.1
|
git+https://github.com/pallets-eco/flask-sqlalchemy.git@aa7a61a5357cf6f5dcc135d98c781192457aa6fa#egg=Flask-SQLAlchemy==2.5.1
|
||||||
Flask==2.1.2
|
Flask==2.1.2
|
||||||
click-datetime==0.2
|
click-datetime==0.2
|
||||||
# Should be pinned until a new gunicorn release greater than 20.1.0 comes out. (Due to eventlet v0.33 compatibility issues)
|
# Should be pinned until a new gunicorn release greater than 20.1.0 comes out. (Due to eventlet v0.33 compatibility issues)
|
||||||
@@ -25,6 +25,7 @@ lxml==4.9.1
|
|||||||
defusedxml==0.7.1
|
defusedxml==0.7.1
|
||||||
Werkzeug==2.1.1
|
Werkzeug==2.1.1
|
||||||
python-dotenv==0.20.0
|
python-dotenv==0.20.0
|
||||||
|
oscrypto
|
||||||
|
|
||||||
notifications-python-client==6.3.0
|
notifications-python-client==6.3.0
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ flask-migrate==3.1.0
|
|||||||
# via -r requirements.in
|
# via -r requirements.in
|
||||||
flask-redis==0.4.0
|
flask-redis==0.4.0
|
||||||
# via notifications-utils
|
# via notifications-utils
|
||||||
flask-sqlalchemy==2.5.1
|
flask-sqlalchemy @ git+https://github.com/pallets-eco/flask-sqlalchemy.git@aa7a61a5357cf6f5dcc135d98c781192457aa6fa
|
||||||
# via
|
# via
|
||||||
# -r requirements.in
|
# -r requirements.in
|
||||||
# flask-migrate
|
# flask-migrate
|
||||||
|
|||||||
Reference in New Issue
Block a user