mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
notify-api-412 use black to enforce python style standards
This commit is contained in:
@@ -7,26 +7,22 @@ from app.config import QueueNames
|
||||
from app.errors import InvalidRequest
|
||||
from app.notifications.sns_handlers import sns_notification_handler
|
||||
|
||||
ses_callback_blueprint = Blueprint('notifications_ses_callback', __name__)
|
||||
ses_callback_blueprint = Blueprint("notifications_ses_callback", __name__)
|
||||
DEFAULT_MAX_AGE = timedelta(days=10000)
|
||||
|
||||
|
||||
# 400 counts as a permanent failure so SNS will not retry.
|
||||
# 500 counts as a failed delivery attempt so SNS will retry.
|
||||
# See https://docs.aws.amazon.com/sns/latest/dg/DeliveryPolicies.html#DeliveryPolicies
|
||||
@ses_callback_blueprint.route('/notifications/email/ses', methods=['POST'])
|
||||
@ses_callback_blueprint.route("/notifications/email/ses", methods=["POST"])
|
||||
def email_ses_callback_handler():
|
||||
try:
|
||||
data = sns_notification_handler(request.data, request.headers)
|
||||
except InvalidRequest as e:
|
||||
return jsonify(
|
||||
result="error", message=str(e.message)
|
||||
), e.status_code
|
||||
return jsonify(result="error", message=str(e.message)), e.status_code
|
||||
|
||||
message = data.get("Message")
|
||||
if "mail" in message:
|
||||
process_ses_results.apply_async([{"Message": message}], queue=QueueNames.NOTIFY)
|
||||
|
||||
return jsonify(
|
||||
result="success", message="SES-SNS callback succeeded"
|
||||
), 200
|
||||
return jsonify(result="success", message="SES-SNS callback succeeded"), 200
|
||||
|
||||
Reference in New Issue
Block a user