From 3fe94a67b0d03bb414533a1753c3b748769f5151 Mon Sep 17 00:00:00 2001 From: sabaimran <65192171+sabaimran@users.noreply.github.com> Date: Wed, 10 Apr 2024 07:27:33 -0700 Subject: [PATCH] Send welcome emails when a new user signs up (#691) * Don't trigger any re-indexing on server initailization * Integrate Resend to send welcome emails when a new user signs up - Only send if this is the first time they've signed in - Configure welcome email with basic styling, as more complex designs don't work and style tag did not work --- pyproject.toml | 1 + src/khoj/app/settings.py | 2 +- src/khoj/configure.py | 30 ++++++------- src/khoj/interface/email/welcome.html | 61 +++++++++++++++++++++++++++ src/khoj/routers/api.py | 2 +- src/khoj/routers/auth.py | 7 ++- src/khoj/routers/email.py | 38 +++++++++++++++++ 7 files changed, 123 insertions(+), 18 deletions(-) create mode 100644 src/khoj/interface/email/welcome.html create mode 100644 src/khoj/routers/email.py diff --git a/pyproject.toml b/pyproject.toml index e446a2a1..c8858365 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -94,6 +94,7 @@ prod = [ "stripe == 7.3.0", "twilio == 8.11", "boto3 >= 1.34.57", + "resend >= 0.8.0", ] dev = [ "khoj-assistant[prod]", diff --git a/src/khoj/app/settings.py b/src/khoj/app/settings.py index 8c17ec23..c8840f1f 100644 --- a/src/khoj/app/settings.py +++ b/src/khoj/app/settings.py @@ -151,7 +151,7 @@ USE_TZ = True # https://docs.djangoproject.com/en/4.2/howto/static-files/ STATIC_ROOT = BASE_DIR / "static" -STATICFILES_DIRS = [BASE_DIR / "interface/web"] +STATICFILES_DIRS = [BASE_DIR / "interface/web", BASE_DIR / "interface/email"] STATIC_URL = "/static/" # Default primary key field type diff --git a/src/khoj/configure.py b/src/khoj/configure.py index 554de35c..60aaf658 100644 --- a/src/khoj/configure.py +++ b/src/khoj/configure.py @@ -231,7 +231,10 @@ def configure_server( state.SearchType = configure_search_types() state.search_models = configure_search(state.search_models, state.config.search_type) setup_default_agent() - initialize_content(regenerate, search_type, init, user) + + if not init: + initialize_content(regenerate, search_type, user) + except Exception as e: raise e @@ -240,23 +243,20 @@ def setup_default_agent(): AgentAdapters.create_default_agent() -def initialize_content(regenerate: bool, search_type: Optional[SearchType] = None, init=False, user: KhojUser = None): +def initialize_content(regenerate: bool, search_type: Optional[SearchType] = None, user: KhojUser = None): # Initialize Content from Config if state.search_models: try: - if init: - logger.info("📬 No-op...") - else: - logger.info("📬 Updating content index...") - all_files = collect_files(user=user) - status = configure_content( - all_files, - regenerate, - search_type, - user=user, - ) - if not status: - raise RuntimeError("Failed to update content index") + logger.info("📬 Updating content index...") + all_files = collect_files(user=user) + status = configure_content( + all_files, + regenerate, + search_type, + user=user, + ) + if not status: + raise RuntimeError("Failed to update content index") except Exception as e: raise e diff --git a/src/khoj/interface/email/welcome.html b/src/khoj/interface/email/welcome.html new file mode 100644 index 00000000..e10f392a --- /dev/null +++ b/src/khoj/interface/email/welcome.html @@ -0,0 +1,61 @@ + + +
+
+
+Hi {{name}}! We are psyched to be part of your journey with personal AI. To better help you, we're committed to staying transparent, accessible, and completely open-source.
+ Get Started +You're about to get a whole lot more more productive.
+ +You don't need to click around Google results and sift through information yourself, because Khoj is connected to the internet.
+Khoj can fill the need for more specialized assistance, such as tutoring, with its curated agents. You get a whole team, always available.
+Build on top of your digital brain. Khoj stores whatever data you share with it, so you can get answers from your personal notes and documents in your native language. You can engage from your desktop, Obsidian, WhatsApp, or the web.
+With your shared data, Khoj can help you create astoundingly personal images depicting scenes of what's important to you.
+Like something? Dislike something? Searching for some other magical feature? Our inbox is always open for feedback! Contact us on team@khoj.dev at anytime.
+ +- The Khoj Team
+| Docs | +GitHub | +Discord | +