diff --git a/api/v1/routes/newsletter.py b/api/v1/routes/newsletter.py index 2fc6b857..c8ddf33a 100644 --- a/api/v1/routes/newsletter.py +++ b/api/v1/routes/newsletter.py @@ -37,20 +37,23 @@ async def sub_newsletter( # Save user to the database NewsletterService.create(db, request) - link = "https://anchor-python.teams.hng.tech/" - - # Send email in the background - background_tasks.add_task( - send_email, - recipient=request.email, - template_name="newsletter-subscription.html", - subject="Thank You for Subscribing to HNG Boilerplate Newsletters", - context={"link": link}, - ) + link = "https://anchor-python.teams.hng.tech/" + + # Send email in the background + background_tasks.add_task( + send_email, + recipient=request.email, + template_name="newsletter-subscription.html", + subject="Thank You for Subscribing to HNG Boilerplate Newsletters", + context={"link": link}, + ) + message = "Thank you for subscribing to our newsletter." + else: + message = "You have already subscribed to our newsletter. Thank you." return success_response( - message="Thank you for subscribing to our newsletter.", - status_code=status.HTTP_201_CREATED, + message=message, + status_code=status.HTTP_200_OK, ) diff --git a/requirements.txt b/requirements.txt index 61534217..e8b8a8e4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,6 +6,7 @@ alembic==1.13.2 annotated-types==0.7.0 anyio==4.4.0 astroid==3.2.4 +async-timeout==4.0.3 attrs==23.2.0 Authlib==1.3.1 autopep8==2.3.1 @@ -23,6 +24,7 @@ colorama==0.4.6 cryptography==43.0.0 cssselect==1.2.0 cssutils==2.11.1 +Deprecated==1.2.14 dill==0.3.8 distlib==0.3.8 dnspython==2.6.1 @@ -37,17 +39,18 @@ filelock==3.15.4 flake8==7.1.0 frozenlist==1.4.1 greenlet==3.0.3 -slowapi==0.1.9 h11==0.14.0 httpcore==1.0.5 httptools==0.6.1 httpx==0.27.0 identify==2.6.0 idna==3.7 +importlib_resources==6.4.4 iniconfig==2.0.0 isort==5.13.2 itsdangerous==2.2.0 Jinja2==3.1.4 +limits==3.13.0 lxml==5.2.2 Mako==1.3.5 markdown-it-py==3.0.0 @@ -61,8 +64,8 @@ nodeenv==1.9.1 packaging==24.1 passlib==1.7.4 pathspec==0.12.1 +pillow==10.4.0 pipdeptree==2.23.1 -Pillow==10.4.0 platformdirs==4.2.2 pluggy==1.5.0 pre-commit==3.7.1 @@ -94,9 +97,11 @@ rich==13.7.1 rsa==4.9 shellingham==1.5.4 six==1.16.0 +slowapi==0.1.9 sniffio==1.3.1 SQLAlchemy==2.0.31 starlette==0.37.2 +stripe==10.7.0 tomli==2.0.1 tomlkit==0.13.0 twilio==9.2.3 @@ -110,5 +115,5 @@ virtualenv==20.26.3 watchfiles==0.22.0 webencodings==0.5.1 websockets==12.0 +wrapt==1.16.0 yarl==1.9.4 -stripe==10.7.0