2017-04-28 16:10:41 +01:00
|
|
|
from flask import current_app
|
2017-04-25 14:38:38 +01:00
|
|
|
import requests
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def confirm_subscription(confirmation_request):
|
2017-04-28 16:10:41 +01:00
|
|
|
url = confirmation_request.get('SubscribeURL')
|
|
|
|
|
if not url:
|
|
|
|
|
current_app.logger.warning("SubscribeURL does not exist or empty")
|
|
|
|
|
return
|
|
|
|
|
|
2017-04-25 14:38:38 +01:00
|
|
|
response = requests.get(url)
|
2017-04-28 16:10:41 +01:00
|
|
|
try:
|
|
|
|
|
response.raise_for_status()
|
|
|
|
|
except Exception as e:
|
|
|
|
|
current_app.logger.warning("Response: {}".format(response.text))
|
|
|
|
|
raise e
|
|
|
|
|
|
2017-04-25 17:01:38 +01:00
|
|
|
return confirmation_request['TopicArn']
|