fix: EmailServiceでインラインスタイルを適用するように (#14600)

Co-authored-by: Esurio <esurio@esurio1673.net>
This commit is contained in:
Esurio/1673beta
2024-09-21 18:18:52 +09:00
committed by GitHub
parent d3f1b0f090
commit d4d15f338e
3 changed files with 266 additions and 13 deletions

View File

@@ -5,6 +5,7 @@
import { URLSearchParams } from 'node:url';
import * as nodemailer from 'nodemailer';
import juice from 'juice';
import { Inject, Injectable } from '@nestjs/common';
import { validate as validateEmail } from 'deep-email-validator';
import { MetaService } from '@/core/MetaService.js';
@@ -61,14 +62,7 @@ export class EmailService {
} : undefined,
} as any);
try {
// TODO: htmlサニタイズ
const info = await transporter.sendMail({
from: meta.email!,
to: to,
subject: subject,
text: text,
html: `<!doctype html>
const htmlContent = `<!doctype html>
<html>
<head>
<meta charset="utf-8">
@@ -147,7 +141,18 @@ export class EmailService {
<a href="${ this.config.url }">${ this.config.host }</a>
</nav>
</body>
</html>`,
</html>`;
const inlinedHtml = juice(htmlContent);
try {
// TODO: htmlサニタイズ
const info = await transporter.sendMail({
from: meta.email!,
to: to,
subject: subject,
text: text,
html: inlinedHtml,
});
this.logger.info(`Message sent: ${info.messageId}`);