Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(schemas): add new email templates table #7002

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

simeng-li
Copy link
Contributor

@simeng-li simeng-li commented Feb 6, 2025

Summary

In the previous implementation, we only supported one copy of the email templates configured under the email connector's settings. This becomes a limitation for some of our customers who require i18n support for their email templates. Users from different regions may receive emails in different languages, just like our SIE i18n phrases. We need to support i18n templates to meet the requirements

In addition to the current default email templates stored in connector configs, we need to add an extra global setting to allow users to configure multiple email templates for different languages. This PR introduces the new email_templates table.

This table will be used to globally maintain custom email templates with i18n support for developers. We will detect the user's language preference and locate the corresponding email template using the following priority:

  • p0: If the language auto-detection is enabled in SIE, we will use the user's browser language preference to locate the email template. (e.g. Accept-Language: en-US)
  • p1: If the language auto-detection is enabled in SIE, but the API request does not contain the Accept-Language header (e.g. Management API triggered email sending flow), use the locale value stored in the user's profile data.
  • p2: If the language auto-detection is enabled in SIE, but the user's profile does not have the locale value, use the default language in SIE.
  • p3: If the language auto-detection is disabled in SIE, use the default language in SIE.
  • fallback: If the email template for the detected language is not found, use the default email template from the connector settings. (Current behavior)

Note

These new i18n email templates will be used globally regardless of the email connector.
We use a shared schema type to define all the email template details. The connector-level template key mapping logic is needed based on different email connectors' interface definitions.
The following email connectors do not support custom email templates. i18n and template customization will be managed by the email provider:

  • Postmark
  • HTML Email
  • Logto cloud email service. (Read-only i18n email templates will be provided by Logto cloud service)

Testing

N/A

Checklist

  • .changeset
  • unit tests
  • integration tests
  • necessary TSDoc comments

Copy link

github-actions bot commented Feb 6, 2025

COMPARE TO master

Total Size Diff 📈 +3.3 KB

Diff by File
Name Diff
packages/schemas/alterations/next-1738828268-add-email-templates-table.ts 📈 +1.27 KB
packages/schemas/src/foundations/jsonb-types/email-templates.ts 📈 +1.29 KB
packages/schemas/src/foundations/jsonb-types/index.ts 📈 +38 Bytes
packages/schemas/tables/email_templates.sql 📈 +725 Bytes

@simeng-li simeng-li requested review from a team February 6, 2025 08:23
add new email templates table
fix the alteration script syntax error
@simeng-li simeng-li force-pushed the simeng-log-10755-schema-add-new-email-template-table branch from 8765c00 to 32c1e3e Compare February 7, 2025 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

2 participants