Skip to content

Commit

Permalink
Remove direct access to settings from thread.
Browse files Browse the repository at this point in the history
Resolves #75
  • Loading branch information
LeoneBacciu committed Sep 2, 2023
1 parent 6d464f1 commit f97cfe5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions django_email_verification/confirm.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ def send_inner(user, thread, expiry, kind, context=None):
subject = _get_validated_field(f'EMAIL_{kind}_SUBJECT')
mail_plain = _get_validated_field(f'EMAIL_{kind}_PLAIN')
mail_html = _get_validated_field(f'EMAIL_{kind}_HTML')
debug = _get_validated_field('DEBUG', default_type=bool)

args = (user, kind, token, expiry, sender, domain, subject, mail_plain, mail_html, context)
args = (user, kind, token, expiry, sender, domain, subject, mail_plain, mail_html, debug, context)
if thread:
t = Thread(target=send_email_thread, args=args)
t.start()
Expand All @@ -56,7 +57,8 @@ def send_inner(user, thread, expiry, kind, context=None):
logger.info(repr(e))


def send_email_thread(user, kind, token, expiry, sender, domain, subject, mail_plain, mail_html, context=None):
def send_email_thread(user, kind, token, expiry, sender, domain, subject, mail_plain, mail_html, debug=False,
context=None):
domain += '/' if not domain.endswith('/') else ''

if context is None:
Expand Down Expand Up @@ -92,7 +94,7 @@ def has_decorator(k):
html = render_to_string(mail_html, context)

msg = EmailMultiAlternatives(subject, text, sender, [user.email])
if settings.DEBUG:
if debug:
msg.extra_headers['LINK'] = context['link']
msg.extra_headers['TOKEN'] = token

Expand Down

0 comments on commit f97cfe5

Please sign in to comment.