From 5b7e7a9a4352d8beccdee3605e65530523aba7c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EB=AF=BC=EC=88=98=20MINSOO=20KIM?= Date: Fri, 10 Mar 2023 17:37:11 +0900 Subject: [PATCH] feat: add comment email template to foramted date with date-fns (#45) --- packages/server/package.json | 1 + .../src/providers/aws/ses/ses.service.ts | 216 ++++++++++-------- pnpm-lock.yaml | 2 + 3 files changed, 126 insertions(+), 93 deletions(-) diff --git a/packages/server/package.json b/packages/server/package.json index 8a6a551..e21bf78 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -33,6 +33,7 @@ "class-transformer": "^0.5.1", "class-validator": "^0.14.0", "cookie-parser": "^1.4.6", + "date-fns": "^2.29.3", "helmet": "^6.0.1", "nanoid": "3.3.4", "passport": "^0.6.0", diff --git a/packages/server/src/providers/aws/ses/ses.service.ts b/packages/server/src/providers/aws/ses/ses.service.ts index 30094aa..e441519 100644 --- a/packages/server/src/providers/aws/ses/ses.service.ts +++ b/packages/server/src/providers/aws/ses/ses.service.ts @@ -2,6 +2,8 @@ import { Injectable } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { SESClient, SendEmailCommand } from '@aws-sdk/client-ses'; import * as sanitizeHtml from 'sanitize-html'; +import { format } from 'date-fns'; + @Injectable() export class SESService { private readonly sesClient: SESClient; @@ -36,6 +38,10 @@ export class SESService { Data: subject, }, Body: { + Html: { + Charset: 'UTF-8', + Data: body, + }, Text: { Charset: 'UTF-8', Data: sanitizeHtml(body, { allowedTags: [] }), @@ -59,101 +65,125 @@ export class SESService { const commentUserLink = `https://wap-dev.store/user/${commentUsername}`; return ` - - - - - - - - - - - + +
- - - + + + + + + + +
+ + + + + + + + + + - -
+ -

Emotions

-

- 새로운 댓글이 달렸습니다. -

- - - - + - - - - -
- -

- ${postTitle} -

-
-
-
- - - -
-
-

- ${commentUsername} +

+

Emotions

+

+ 새로운 댓글이 달렸습니다.

-

${commentText}

- - -
- -

- @neko113 // Follow 및 Star는 개발자에게 큰 힘이 됩니다. -

-
-
-
- - - +
+ +

+ ${postTitle} +

+
+
+
+ + + +
+
+
+
+ ${commentUsername} +
+
+ ${format( + new Date(), + 'yyyy.MM.dd HH:mm:ss', + )}
+
+
+ ${commentText} +
+
+
+
+ +

+ @neko113 // Follow 및 Star는 개발자에게 큰 힘이 됩니다. +

+
+
+
+ + + `; } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b46ffd1..c6ddbb3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -139,6 +139,7 @@ importers: class-transformer: ^0.5.1 class-validator: ^0.14.0 cookie-parser: ^1.4.6 + date-fns: ^2.29.3 helmet: ^6.0.1 nanoid: 3.3.4 passport: ^0.6.0 @@ -173,6 +174,7 @@ importers: class-transformer: 0.5.1 class-validator: 0.14.0 cookie-parser: 1.4.6 + date-fns: 2.29.3 helmet: 6.0.1 nanoid: 3.3.4 passport: 0.6.0