offloaded some apps.lyric.views responsibilities to new Celery depend fn in .tasks; core.celery created for celery config; CELERY_BROKER_URL added to .settings & throughout project; some lyric view IT responsibility now accordingly covered by task UT domain
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
This commit is contained in:
24
src/apps/lyric/tasks.py
Normal file
24
src/apps/lyric/tasks.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import requests
|
||||
|
||||
from celery import shared_task
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
@shared_task
|
||||
def send_login_email_task(email, url):
|
||||
message_body = f"Use this magic link to login to your Dashboard:\n\n{url}"
|
||||
# Send mail via Mailgun HTTP API
|
||||
response = requests.post(
|
||||
f"https://api.mailgun.net/v3/{settings.MAILGUN_DOMAIN}/messages",
|
||||
auth=("api", settings.MAILGUN_API_KEY),
|
||||
data={
|
||||
"from": "adman@howdy.earthmanrpg.com",
|
||||
"to": email,
|
||||
"subject": "A magic login link to your Dashboard",
|
||||
"text": message_body,
|
||||
}
|
||||
)
|
||||
|
||||
# Log any errors
|
||||
if response.status_code != 200:
|
||||
print(f"Mailgun API error: {response.status_code}: {response.text}")
|
||||
Reference in New Issue
Block a user