mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-12-17 18:17:10 +00:00
Do not create an import error if the resend module is not available
This commit is contained in:
parent
f04ead7c37
commit
b0059654c9
1 changed files with 8 additions and 5 deletions
|
@ -1,7 +1,11 @@
|
|||
import logging
|
||||
import os
|
||||
|
||||
try:
|
||||
import resend
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
from django.conf import settings
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
|
||||
|
@ -17,16 +21,15 @@ static_files = os.path.join(settings.BASE_DIR, "static")
|
|||
env = Environment(loader=FileSystemLoader(static_files))
|
||||
|
||||
if not RESEND_API_KEY:
|
||||
logger.info("RESEND_API_KEY not set - email sending disabled")
|
||||
logger.warn("RESEND_API_KEY not set - email sending disabled")
|
||||
else:
|
||||
resend.api_key = RESEND_API_KEY
|
||||
|
||||
|
||||
def is_resend_enabled():
|
||||
return bool(RESEND_API_KEY)
|
||||
|
||||
|
||||
resend.api_key = RESEND_API_KEY
|
||||
|
||||
|
||||
async def send_welcome_email(name, email):
|
||||
if not is_resend_enabled():
|
||||
logger.debug("Email sending disabled")
|
||||
|
|
Loading…
Reference in a new issue