Skip to content

Commit

Permalink
Minor: SQS Confirmation Class (#39)
Browse files Browse the repository at this point in the history
* Add in subscription confirmation handling

Co-authored-by: Max Anderson <maxwell.c.anderson@gmail.com>
  • Loading branch information
rjulian and mcbanderson committed Sep 5, 2020
1 parent ff16971 commit 8f8b531
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
1 change: 1 addition & 0 deletions reflex_core/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
boto3
requests
30 changes: 30 additions & 0 deletions reflex_core/subscription_confirmation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
""" Module for the SubscriptionConfirmation class """
import logging
import os

import requests

LOG_LEVEL = os.environ.get("LOG_LEVEL", "INFO").upper()
LOGGER = logging.getLogger()
LOGGER.setLevel(LOG_LEVEL)


def is_subscription_confirmation(event):
"""Determines if event payload is for confirming subscriptions."""
return event.get("Type") == "SubscriptionConfirmation"


def confirm_subscription(event):
"""Respond to an outside subscription notification.
For SNS topic subscriptions that require manual subscription confirmations, this
function will parse the event message and make the request to the confirmation
url.
Returns:
None
"""

subscription_url = event.get("SubscribeURL")
LOGGER.info("Confirming subscription by requesting URL: %s", subscription_url)
requests.get(subscription_url)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
long_description_content_type="text/markdown",
url="https://github.com/pangolock/reflex-core",
packages=setuptools.find_packages(),
install_requires=["boto3"],
install_requires=["boto3", "requests"],
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)",
Expand Down

0 comments on commit 8f8b531

Please sign in to comment.