Skip to content

Commit 1b219c4

Browse files
authored
Merge pull request #639 from Hexastack/fix/mailing
fix: nest mailing + minor css tweaks
2 parents ad07884 + 44eff3d commit 1b219c4

File tree

6 files changed

+41
-11
lines changed

6 files changed

+41
-11
lines changed

api/nest-cli.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
"sourceRoot": "src",
55
"compilerOptions": {
66
"deleteOutDir": true,
7-
"assets": [{ "include": "config/i18n/**/*", "watchAssets": true }]
7+
"assets": [
8+
{ "include": "config/i18n/**/*", "watchAssets": true },
9+
{ "include": "templates/**/*.mjml", "watchAssets": true }
10+
]
811
}
912
}

api/patches/@nestjs-modules+mailer+1.11.2.patch

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,30 @@
1+
diff --git a/node_modules/@nestjs-modules/mailer/dist/adapters/mjml.adapter.js b/node_modules/@nestjs-modules/mailer/dist/adapters/mjml.adapter.js
2+
index 5eb7a4a..afaaaa9 100644
3+
--- a/node_modules/@nestjs-modules/mailer/dist/adapters/mjml.adapter.js
4+
+++ b/node_modules/@nestjs-modules/mailer/dist/adapters/mjml.adapter.js
5+
@@ -26,8 +26,20 @@ class MjmlAdapter {
6+
compile(mail, callback, mailerOptions) {
7+
var _a;
8+
(_a = this === null || this === void 0 ? void 0 : this.engine) === null || _a === void 0 ? void 0 : _a.compile(mail, () => {
9+
- mail.data.html = mjml2html(mail.data.html).html;
10+
- callback();
11+
+ Promise.resolve(mail.data.html).then((html) => {
12+
+ Promise.resolve(mjml2html(html)).then((result) => {
13+
+ mail.data.html = result.html;
14+
+ callback();
15+
+ }).catch((err) => {
16+
+ console.error('@nestjs-modules/mailer: Unable to convert mjml to html', err)
17+
+ mail.data.html = '';
18+
+ callback();
19+
+ })
20+
+ }).catch((err) => {
21+
+ console.error('@nestjs-modules/mailer: Unable to compiling mjml', err)
22+
+ mail.data.html = '';
23+
+ callback();
24+
+ })
25+
}, mailerOptions);
26+
}
27+
}
128
diff --git a/node_modules/@nestjs-modules/mailer/dist/mailer.service.js b/node_modules/@nestjs-modules/mailer/dist/mailer.service.js
229
index 016055b..d534240 100644
330
--- a/node_modules/@nestjs-modules/mailer/dist/mailer.service.js

api/src/app.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ const i18nOptions: I18nOptions = {
7272
}),
7373
template: {
7474
adapter: new MjmlAdapter('ejs', { inlineCssEnabled: false }),
75-
dir: './src/templates',
75+
dir: path.join(process.cwd(), 'dist', 'templates'),
7676
options: {
7777
context: {
7878
appName: config.parameters.appName,

api/src/templates/account_confirmation.mjml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<mj-body>
33
<mj-section>
44
<mj-column>
5-
<mj-image width="100px" src="/assets/logo.png"></mj-image>
6-
<mj-divider border-color="#048BA8"></mj-divider>
5+
<mj-image width="186px" src="https://hexabot.ai/assets/images/logo.png"></mj-image>
6+
<mj-divider border-color="#000"></mj-divider>
77
<mj-text font-size="16px" color="#000" font-family="helvetica"
88
><%= t('hi') %> <%= first_name %>,</mj-text
99
>
@@ -17,7 +17,7 @@
1717
<mj-button
1818
href="<%= this.appUrl %>/login/<%= token %>"
1919
font-size="16px"
20-
background-color="#F45E43"
20+
background-color="#000"
2121
><%= t('confirm') %></mj-button
2222
>
2323
</mj-column>

api/src/templates/invitation.mjml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<mj-body>
33
<mj-section>
44
<mj-column>
5-
<mj-image width="100px" src="/assets/logo.png"></mj-image>
6-
<mj-divider border-color="#048BA8"></mj-divider>
5+
<mj-image width="186px" src="https://hexabot.ai/assets/images/logo.png"></mj-image>
6+
<mj-divider border-color="#000"></mj-divider>
77
<mj-text font-size="16px" color="#000" font-family="helvetica">
88
<%= t('welcome') %>,
99
</mj-text>
@@ -19,7 +19,7 @@
1919
<mj-button
2020
href="<%= this.appUrl %>/register/<%= token %>"
2121
font-size="16px"
22-
background-color="#F45E43"
22+
background-color="#000"
2323
><%= t('join') %></mj-button
2424
>
2525
</mj-column>

api/src/templates/password_reset.mjml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
<mj-body>
33
<mj-section>
44
<mj-column>
5-
<mj-image width="100px" src="/assets/logo.png"></mj-image>
6-
<mj-divider border-color="#048BA8"></mj-divider>
5+
<mj-image width="186px" src="https://hexabot.ai/assets/images/logo.png"></mj-image>
6+
<mj-divider border-color="#000"></mj-divider>
77
<mj-text font-size="16px" color="#000" font-family="helvetica"
88
><%= t('hi') %> <%= first_name %>,</mj-text
99
>
@@ -16,7 +16,7 @@
1616
<mj-button
1717
href="<%= this.appUrl %>/reset/<%= token %>"
1818
font-size="16px"
19-
background-color="#F45E43"
19+
background-color="#000"
2020
><%= t('reset') %></mj-button
2121
>
2222
</mj-column>

0 commit comments

Comments
 (0)