mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-12-18 02:27: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 logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import resend
|
try:
|
||||||
|
import resend
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from jinja2 import Environment, FileSystemLoader
|
from jinja2 import Environment, FileSystemLoader
|
||||||
|
|
||||||
|
@ -17,16 +21,15 @@ static_files = os.path.join(settings.BASE_DIR, "static")
|
||||||
env = Environment(loader=FileSystemLoader(static_files))
|
env = Environment(loader=FileSystemLoader(static_files))
|
||||||
|
|
||||||
if not RESEND_API_KEY:
|
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():
|
def is_resend_enabled():
|
||||||
return bool(RESEND_API_KEY)
|
return bool(RESEND_API_KEY)
|
||||||
|
|
||||||
|
|
||||||
resend.api_key = RESEND_API_KEY
|
|
||||||
|
|
||||||
|
|
||||||
async def send_welcome_email(name, email):
|
async def send_welcome_email(name, email):
|
||||||
if not is_resend_enabled():
|
if not is_resend_enabled():
|
||||||
logger.debug("Email sending disabled")
|
logger.debug("Email sending disabled")
|
||||||
|
|
Loading…
Reference in a new issue