diff --git a/app/core/mail.py b/app/core/mail.py index 803743f..5906601 100644 --- a/app/core/mail.py +++ b/app/core/mail.py @@ -44,7 +44,14 @@ def send_email( if template_name and template_context is not None and jinja_env: try: template = jinja_env.get_template(template_name) - html_body = template.render(**template_context) + # asset_base_url is injected for every template so image URLs follow + # the deployed frontend instead of being hardcoded. A call site can + # override it by passing its own value in template_context. + context = { + "asset_base_url": settings.EMAIL_ASSET_BASE_URL, + **template_context, + } + html_body = template.render(**context) if not body: body = f"Please view this email in an HTML-compatible client. Subject: {subject}" except Exception as e: diff --git a/app/core/settings.py b/app/core/settings.py index db3543e..81c422e 100644 --- a/app/core/settings.py +++ b/app/core/settings.py @@ -196,6 +196,17 @@ class Settings(BaseSettings): FRONTEND_URL: str = "http://localhost:5173" + @property + def EMAIL_ASSET_BASE_URL(self) -> str: + """Origin serving the email images in docqube_frontend/public/email/. + + These are frontend static assets, so they hang off FRONTEND_URL rather + than the API. FRONTEND_URL is a comma-separated list in some + environments (see .env.test), so take the first entry. + """ + base = self.FRONTEND_URL.split(",")[0].strip().rstrip("/") + return f"{base}/email" + LOG_LEVEL: str CORS_ORIGINS: str diff --git a/app/templates/emails/document_shared.html b/app/templates/emails/document_shared.html index 70063b0..8539ebd 100644 --- a/app/templates/emails/document_shared.html +++ b/app/templates/emails/document_shared.html @@ -1,54 +1,672 @@ - + +
-|
- - {{ sharer_name }} shared - {{ document_name }} with you on DocQube. - +
|
+ ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
+
+
+
+
|
+
| + |
+
+
+ |
-
- |
|