mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-02 20:58:38 -04:00
fix migrations
This commit is contained in:
@@ -118,6 +118,7 @@ class Config(object):
|
||||
NOTIFY_EMAIL_DOMAIN = 'notify.sandbox.10x.gsa.gov'
|
||||
|
||||
# AWS SNS topics for delivery receipts
|
||||
VALIDATE_SNS_TOPICS = True
|
||||
VALID_SNS_TOPICS = ['notify_test_bounce', 'notify_test_success', 'notify_test_complaint', 'notify_test_sms_inbound']
|
||||
|
||||
# URL of redis instance
|
||||
|
||||
@@ -27,6 +27,7 @@ INBOUND_SMS_COUNTER = Counter(
|
||||
@receive_notifications_blueprint.route('/notifications/sms/receive/sns', methods=['POST'])
|
||||
def receive_sns_sms():
|
||||
"""
|
||||
Expected value of the 'Message' key in the incoming payload from SNS
|
||||
{
|
||||
"originationNumber":"+14255550182",
|
||||
"destinationNumber":"+12125550101",
|
||||
|
||||
@@ -10,8 +10,7 @@ import six
|
||||
from app import redis_store
|
||||
from app.config import Config
|
||||
|
||||
USE_CACHE = True
|
||||
VALIDATE_ARN = True
|
||||
VALIDATE_SNS_TOPICS = Config.VALIDATE_SNS_TOPICS
|
||||
VALID_SNS_TOPICS = Config.VALID_SNS_TOPICS
|
||||
|
||||
|
||||
@@ -27,19 +26,16 @@ class ValidationError(Exception):
|
||||
|
||||
|
||||
def get_certificate(url):
|
||||
if USE_CACHE:
|
||||
res = redis_store.get(url)
|
||||
if res is not None:
|
||||
return res
|
||||
res = requests.get(url).text
|
||||
redis_store.set(url, res, ex=60 * 60) # 60 minutes
|
||||
res = redis_store.get(url)
|
||||
if res is not None:
|
||||
return res
|
||||
else:
|
||||
return requests.get(url).text
|
||||
res = requests.get(url).text
|
||||
redis_store.set(url, res, ex=60 * 60) # 60 minutes
|
||||
return res
|
||||
|
||||
|
||||
def validate_arn(sns_payload):
|
||||
if VALIDATE_ARN:
|
||||
if VALIDATE_SNS_TOPICS:
|
||||
arn = sns_payload.get('TopicArn')
|
||||
topic_name = arn.split(':')[5]
|
||||
if topic_name not in VALID_SNS_TOPICS:
|
||||
|
||||
Reference in New Issue
Block a user