forked from github/plane
* dev: remove len for empty comparison * dev: using in instead of multiple ors * dev: assign expression to empty variables * dev: use f-string * dev: remove list comprehension and use generators * dev: remove assert from paginator * dev: use is for identity comparison with singleton * dev: remove unnecessary else statements * dev: fix does not exists error for both project and workspace * dev: remove reimports * dev: iterate a dictionary * dev: remove unused commented code * dev: remove redefinition * dev: remove unused imports * dev: remove unused imports * dev: remove unnecessary f strings * dev: remove unused variables * dev: use literal structure to create the data structure * dev: add empty lines at the end of the file * dev: remove user middleware * dev: remove unnecessary default None
47 lines
1.2 KiB
Python
47 lines
1.2 KiB
Python
# Django imports
|
|
from django.core.mail import EmailMultiAlternatives
|
|
from django.template.loader import render_to_string
|
|
from django.utils.html import strip_tags
|
|
from django.conf import settings
|
|
|
|
# Third party imports
|
|
from celery import shared_task
|
|
|
|
|
|
from sentry_sdk import capture_exception
|
|
|
|
# Module imports
|
|
from plane.db.models import User
|
|
|
|
|
|
@shared_task
|
|
def email_verification(first_name, email, token, current_site):
|
|
|
|
try:
|
|
realtivelink = "/request-email-verification/" + "?token=" + str(token)
|
|
abs_url = current_site + realtivelink
|
|
|
|
from_email_string = settings.EMAIL_FROM
|
|
|
|
subject = "Verify your Email!"
|
|
|
|
context = {
|
|
"first_name": first_name,
|
|
"verification_url": abs_url,
|
|
}
|
|
|
|
html_content = render_to_string("emails/auth/email_verification.html", context)
|
|
|
|
text_content = strip_tags(html_content)
|
|
|
|
msg = EmailMultiAlternatives(subject, text_content, from_email_string, [email])
|
|
msg.attach_alternative(html_content, "text/html")
|
|
msg.send()
|
|
return
|
|
except Exception as e:
|
|
# Print logs if in DEBUG mode
|
|
if settings.DEBUG:
|
|
print(e)
|
|
capture_exception(e)
|
|
return
|