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/use handlebars for mailing #828

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
"connect-mongo": "^5.1.0",
"cookie-parser": "^1.4.6",
"dotenv": "^16.3.1",
"ejs": "^3.1.9",
"express-session": "^1.17.3",
"handlebars": "^4.7.8",
"module-alias": "^2.2.3",
Expand Down
10 changes: 9 additions & 1 deletion api/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,15 @@ const i18nOptions: I18nOptions = {
debug: false,
}),
template: {
adapter: new MjmlAdapter('ejs', { inlineCssEnabled: false }),
adapter: new MjmlAdapter(
'handlebars',
{
inlineCssEnabled: false,
},
{
handlebar: {},
},
),
dir: path.join(process.cwd(), 'dist', 'templates'),
options: {
context: {
Expand Down
40 changes: 22 additions & 18 deletions api/src/templates/account_confirmation.mjml
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,38 @@
<mj-body>
<mj-section>
<mj-column>
<mj-image width="186px" src="https://hexabot.ai/assets/images/logo.png"></mj-image>
<mj-image
width="186px"
src="https://hexabot.ai/assets/images/logo.png"
></mj-image>
<mj-divider border-color="#000"></mj-divider>
<mj-text font-size="16px" color="#000" font-family="helvetica"
><%= t('hi') %> <%= first_name %>,</mj-text
>
<mj-text font-size="16px" color="#000" font-family="helvetica"
><%= t('account_successfully_created_confirm_password') %></mj-text
>
<mj-text font-size="16px" color="#000" font-family="helvetica">
{{t 'hi'}} {{first_name}},
</mj-text>
<mj-text font-size="16px" color="#000" font-family="helvetica">
{{t 'account_successfully_created_confirm_password'}}
</mj-text>

<mj-text font-size="16px" color="#000" font-family="helvetica"
><%= t('confirm_account') %></mj-text
>
<mj-text font-size="16px" color="#000" font-family="helvetica">
{{t 'confirm_account'}}
</mj-text>
<mj-button
href="<%= this.appUrl %>/login/<%= token %>"
href="{{appUrl}}/login/{{token}}"
font-size="16px"
background-color="#000"
><%= t('confirm') %></mj-button
>
{{t 'confirm'}}
</mj-button>
</mj-column>
</mj-section>
<mj-section>
<mj-column>
<mj-text font-size="16px" color="#000" font-family="helvetica"
><%= t('best_regards') %></mj-text
>
<mj-text font-size="16px" color="#000" font-family="helvetica"
><%= this.appName %></mj-text
>
<mj-text font-size="16px" color="#000" font-family="helvetica">
{{t 'best_regards'}}
</mj-text>
<mj-text font-size="16px" color="#000" font-family="helvetica">
{{appName}}
</mj-text>
</mj-column>
</mj-section>
</mj-body>
Expand Down
27 changes: 15 additions & 12 deletions api/src/templates/invitation.mjml
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,39 @@
<mj-body>
<mj-section>
<mj-column>
<mj-image width="186px" src="https://hexabot.ai/assets/images/logo.png"></mj-image>
<mj-image
width="186px"
src="https://hexabot.ai/assets/images/logo.png"
></mj-image>
<mj-divider border-color="#000"></mj-divider>
<mj-text font-size="16px" color="#000" font-family="helvetica">
<%= t('welcome') %>,
{{t 'welcome'}}
</mj-text>

<mj-text font-size="16px" color="#000" font-family="helvetica"
><%= `${t('invitation_for_account_creation')} ${this.appName}
${t('account')}.` %></mj-text
>
<mj-text font-size="16px" color="#000" font-family="helvetica">
{{t 'invitation_for_account_creation'}} {{appName}} {{t 'account'}}.
</mj-text>

<mj-text font-size="16px" color="#000" font-family="helvetica"
><%= t('create_account') %></mj-text
>{{ t 'create_account'}}</mj-text
>
<mj-button
href="<%= this.appUrl %>/register/<%= token %>"
href="{{appUrl}}/register/{{token}}"
font-size="16px"
background-color="#000"
><%= t('join') %></mj-button
>
{{t 'join'}}</mj-button
>
</mj-column>
</mj-section>
<mj-section>
<mj-column>
<mj-text font-size="16px" color="#000" font-family="helvetica"
><%= t('best_regards') %></mj-text
>
>{{t 'best_regards'}}
</mj-text>

<mj-text font-size="16px" color="#000" font-family="helvetica"
><%= this.appName %></mj-text
>{{this.appName }}</mj-text
>
</mj-column>
</mj-section>
Expand Down
40 changes: 22 additions & 18 deletions api/src/templates/password_reset.mjml
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,37 @@
<mj-body>
<mj-section>
<mj-column>
<mj-image width="186px" src="https://hexabot.ai/assets/images/logo.png"></mj-image>
<mj-image
width="186px"
src="https://hexabot.ai/assets/images/logo.png"
></mj-image>
<mj-divider border-color="#000"></mj-divider>
<mj-text font-size="16px" color="#000" font-family="helvetica"
><%= t('hi') %> <%= first_name %>,</mj-text
>
<mj-text font-size="16px" color="#000" font-family="helvetica"
><%= t('password_reset_request') %></mj-text
>
<mj-text font-size="16px" color="#000" font-family="helvetica"
><%= t('click_to_reset_password') %></mj-text
>
<mj-text font-size="16px" color="#000" font-family="helvetica">
{{t 'hi'}} {{first_name}},
</mj-text>
<mj-text font-size="16px" color="#000" font-family="helvetica">
{{t 'password_reset_request'}}
</mj-text>
<mj-text font-size="16px" color="#000" font-family="helvetica">
{{t 'click_to_reset_password'}}
</mj-text>
<mj-button
href="<%= this.appUrl %>/reset/<%= token %>"
href="{{appUrl}}/reset/{{token}}"
font-size="16px"
background-color="#000"
><%= t('reset') %></mj-button
>
{{t 'reset'}}
</mj-button>
</mj-column>
</mj-section>
<mj-section>
<mj-column>
<mj-text font-size="16px" color="#000" font-family="helvetica"
><%= t('best_regards') %></mj-text
>
<mj-text font-size="16px" color="#000" font-family="helvetica"
><%= this.appName %></mj-text
>
<mj-text font-size="16px" color="#000" font-family="helvetica">
{{t 'best_regards'}}
</mj-text>
<mj-text font-size="16px" color="#000" font-family="helvetica">
{{appName}}
</mj-text>
</mj-column>
</mj-section>
</mj-body>
Expand Down
2 changes: 1 addition & 1 deletion api/src/user/services/invitation.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright © 2024 Hexastack. All rights reserved.
* Copyright © 2025 Hexastack. All rights reserved.
*
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
Expand Down