remove celery and use dramatiq
This commit is contained in:
@@ -1,14 +1,13 @@
|
||||
import logging
|
||||
|
||||
from celery import shared_task
|
||||
import dramatiq
|
||||
|
||||
from options.options import SysOptions
|
||||
from utils.shortcuts import send_email
|
||||
from utils.shortcuts import send_email, DRAMATIQ_WORKER_ARGS
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@shared_task
|
||||
@dramatiq.actor(**DRAMATIQ_WORKER_ARGS(max_retries=3))
|
||||
def send_email_async(from_name, to_email, to_name, subject, content):
|
||||
if not SysOptions.smtp_config:
|
||||
return
|
||||
|
||||
@@ -302,11 +302,11 @@ class ApplyResetPasswordAPI(APIView):
|
||||
"link": f"{SysOptions.website_base_url}/reset-password/{user.reset_password_token}"
|
||||
}
|
||||
email_html = render_to_string("reset_password_email.html", render_data)
|
||||
send_email_async.delay(from_name=SysOptions.website_name_shortcut,
|
||||
to_email=user.email,
|
||||
to_name=user.username,
|
||||
subject=f"Reset your password",
|
||||
content=email_html)
|
||||
send_email_async.send(from_name=SysOptions.website_name_shortcut,
|
||||
to_email=user.email,
|
||||
to_name=user.username,
|
||||
subject=f"Reset your password",
|
||||
content=email_html)
|
||||
return self.success("Succeeded")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user