Add support for managing audiences for new users

This commit is contained in:
sabaimran
2024-06-08 15:51:17 +05:30
parent 06a47ee457
commit 849c38c0a4

View File

@@ -16,6 +16,7 @@ logger = logging.getLogger(__name__)
RESEND_API_KEY = os.getenv("RESEND_API_KEY")
RESEND_AUDIENCE_ID = os.getenv("RESEND_AUDIENCE_ID")
static_files = os.path.join(settings.BASE_DIR, "static")
@@ -40,7 +41,7 @@ async def send_welcome_email(name, email):
html_content = template.render(name=name if not is_none_or_empty(name) else "you")
r = resend.Emails.send(
resend.Emails.send(
{
"sender": "team@khoj.dev",
"to": email,
@@ -49,6 +50,19 @@ async def send_welcome_email(name, email):
}
)
if not RESEND_AUDIENCE_ID:
return
contact_params = {
"email": email,
"audience_id": RESEND_AUDIENCE_ID,
}
if name:
contact_params["first_name"] = name
resend.Contacts.create(contact_params)
async def send_query_feedback(uquery, kquery, sentiment, user_email):
if not is_resend_enabled():