mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-07 21:29:13 +00:00
Do not create an import error if the resend module is not available
This commit is contained in:
@@ -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")
|
||||||
|
|||||||
Reference in New Issue
Block a user