From 9f8ccc436fd02859a532b052bed278e56c3ca290 Mon Sep 17 00:00:00 2001 From: "makabe.t" Date: Mon, 25 Dec 2023 05:38:28 +0000 Subject: [PATCH] =?UTF-8?q?Merged=20PR=20658:=20=E3=82=A2=E3=82=AB?= =?UTF-8?q?=E3=82=A6=E3=83=B3=E3=83=88=E8=AA=8D=E8=A8=BC=E3=81=AE=E3=81=8A?= =?UTF-8?q?=E9=A1=98=E3=81=84=E9=80=9A=E7=9F=A5=E3=81=AE=E5=AE=9F=E8=A3=85?= =?UTF-8?q?=20[U-102]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 概要 [Task3321: アカウント認証のお願い通知の実装](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/3321) - アカウント登録時の認証メールを送信する機能を追加しました。 ## レビューポイント - 既存のエラー処理はそのままにしていますが不自然な点はないでしょうか? ## UIの変更 - なし ## 動作確認状況 - ローカルで確認 --- .../src/features/accounts/accounts.service.ts | 21 ++----- .../src/gateways/sendgrid/sendgrid.service.ts | 61 +++++++++++++++++++ .../src/templates/template_U_102.html | 60 ++++++++++++++++++ .../src/templates/template_U_102.txt | 26 ++++++++ 4 files changed, 151 insertions(+), 17 deletions(-) create mode 100644 dictation_server/src/templates/template_U_102.html create mode 100644 dictation_server/src/templates/template_U_102.txt diff --git a/dictation_server/src/features/accounts/accounts.service.ts b/dictation_server/src/features/accounts/accounts.service.ts index 2b0eb8f..4e4b474 100644 --- a/dictation_server/src/features/accounts/accounts.service.ts +++ b/dictation_server/src/features/accounts/accounts.service.ts @@ -287,24 +287,11 @@ export class AccountsService { } try { - // メールの内容を構成 - const { subject, text, html } = - await this.sendgridService.createMailContentFromEmailConfirm( - context, - account.id, - user.id, - email, - ); - - // メールを送信 - await this.sendgridService.sendMail( + await this.sendgridService.sendMailWithU102( context, - [email], - [], - this.mailFrom, - subject, - text, - html, + email, + account.id, + user.id, ); } catch (e) { this.logger.error(`[${context.getTrackingId()}] error=${e}`); diff --git a/dictation_server/src/gateways/sendgrid/sendgrid.service.ts b/dictation_server/src/gateways/sendgrid/sendgrid.service.ts index 46a7274..2a39bb5 100644 --- a/dictation_server/src/gateways/sendgrid/sendgrid.service.ts +++ b/dictation_server/src/gateways/sendgrid/sendgrid.service.ts @@ -31,6 +31,8 @@ export class SendGridService { private readonly templateEmailVerifyText: string; private readonly templateU101Html: string; private readonly templateU101Text: string; + private readonly templateU102Html: string; + private readonly templateU102Text: string; private readonly templateU105Html: string; private readonly templateU105Text: string; private readonly templateU106Html: string; @@ -83,6 +85,14 @@ export class SendGridService { path.resolve(__dirname, `../../templates/template_U_101.txt`), 'utf-8', ); + this.templateU102Html = readFileSync( + path.resolve(__dirname, `../../templates/template_U_102.html`), + 'utf-8', + ); + this.templateU102Text = readFileSync( + path.resolve(__dirname, `../../templates/template_U_102.txt`), + 'utf-8', + ); this.templateU105Html = readFileSync( path.resolve(__dirname, `../../templates/template_U_105.html`), @@ -326,6 +336,57 @@ export class SendGridService { } } + /** + * U-102のテンプレートを使用したメールを送信する + * @param context + * @param adminEmail 登録したアカウントの管理者(primary)のメールアドレス + * @param accountId 登録したアカウントのID + * @param userId 登録したユーザーのID + * @returns mail with u102 + */ + async sendMailWithU102( + context: Context, + adminEmail: string, + accountId: number, + userId: number, + ): Promise { + this.logger.log( + `[IN] [${context.getTrackingId()}] ${this.sendMailWithU102.name}`, + ); + try { + const privateKey = getPrivateKey(this.configService); + const token = sign<{ accountId: number; userId: number; email: string }>( + { + accountId, + userId, + email: adminEmail, + }, + this.emailConfirmLifetime, + privateKey, + ); + const path = 'mail-confirm/'; + const verifyUrl = `${this.appDomain}${path}?verify=${token}`; + + const subject = 'User Registration Notification [U-102]'; + const html = this.templateU102Html.replaceAll(VERIFY_LINK, verifyUrl); + const text = this.templateU102Text.replaceAll(VERIFY_LINK, verifyUrl); + + await this.sendMail( + context, + [adminEmail], + [], + this.mailFrom, + subject, + text, + html, + ); + } finally { + this.logger.log( + `[OUT] [${context.getTrackingId()}] ${this.sendMailWithU102.name}`, + ); + } + } + /** * U-105のテンプレートを使用したメールを送信する * @param context diff --git a/dictation_server/src/templates/template_U_102.html b/dictation_server/src/templates/template_U_102.html new file mode 100644 index 0000000..b08db53 --- /dev/null +++ b/dictation_server/src/templates/template_U_102.html @@ -0,0 +1,60 @@ + + + User Registration Notification [U-102] + + +
+

<English>

+

+ Your user information has been registered within the ODMS Cloud by + yourself. To complete your user registration, you must verify your email + address. Please verify by clicking on the link below. Once the + registration is completed, a notification window will appear confirming + that your user information has been verified. +

+

URL: $VERIFY_LINK$

+

+ If you have received this e-mail in error, please delete this e-mail + from your system.
+ This is an automatically generated e-mail and this mailbox is not + monitored. Please do not reply. +

+
+
+

<Deutsch>

+

+ Ihre Benutzerinformationen wurden von Ihnen selbst in der ODMS Cloud + registriert. Um Ihre Benutzerregistrierung abzuschließen, müssen Sie + Ihre E-Mail-Adresse bestätigen. Bitte überprüfen Sie dies, indem Sie auf + den untenstehenden Link klicken. Sobald die Registrierung abgeschlossen + ist, erscheint ein Benachrichtigungsfenster, das bestätigt, dass Ihre + Benutzerinformationen überprüft wurden. +

+

URL: $VERIFY_LINK$

+

+ Wenn Sie diese E-Mail fälschlicherweise erhalten haben, löschen Sie + diese E-Mail bitte aus Ihrem System.
+ Dies ist eine automatisch generierte E-Mail und dieses Postfach wird + nicht überwacht. Bitte nicht antworten. +

+
+
+

<Français>

+

+ Vos informations utilisateur ont été enregistrées par vous-même dans le + cloud ODMS. Pour finaliser votre inscription d'utilisateur, vous devez + vérifier votre adresse e-mail. Veuillez vérifier en cliquant sur le lien + ci-dessous. Une fois l'inscription terminée, une fenêtre de notification + apparaîtra confirmant que vos informations d'utilisateur ont été + vérifiées. +

+

URL: $VERIFY_LINK$

+

+ Si vous avez reçu cet e-mail par erreur, veuillez supprimer cet e-mail + de votre système.
+ Il s'agit d'un e-mail généré automatiquement et cette boîte aux lettres + n'est pas surveillée. Merci de ne pas répondre. +

+
+ + diff --git a/dictation_server/src/templates/template_U_102.txt b/dictation_server/src/templates/template_U_102.txt new file mode 100644 index 0000000..9202e58 --- /dev/null +++ b/dictation_server/src/templates/template_U_102.txt @@ -0,0 +1,26 @@ + + +Your user information has been registered within the ODMS Cloud by yourself. To complete your user registration, you must verify your email address. Please verify by clicking on the link below. Once the registration is completed, a notification window will appear confirming that your user information has been verified. + +URL: $VERIFY_LINK$ + +If you have received this e-mail in error, please delete this e-mail from your system. +This is an automatically generated e-mail and this mailbox is not monitored. Please do not reply. + + + +Ihre Benutzerinformationen wurden von Ihnen selbst in der ODMS Cloud registriert. Um Ihre Benutzerregistrierung abzuschließen, müssen Sie Ihre E-Mail-Adresse bestätigen. Bitte überprüfen Sie dies, indem Sie auf den untenstehenden Link klicken. Sobald die Registrierung abgeschlossen ist, erscheint ein Benachrichtigungsfenster, das bestätigt, dass Ihre Benutzerinformationen überprüft wurden. + +URL: $VERIFY_LINK$ + +Wenn Sie diese E-Mail fälschlicherweise erhalten haben, löschen Sie diese E-Mail bitte aus Ihrem System. +Dies ist eine automatisch generierte E-Mail und dieses Postfach wird nicht überwacht. Bitte nicht antworten. + + + +Vos informations utilisateur ont été enregistrées par vous-même dans le cloud ODMS. Pour finaliser votre inscription d'utilisateur, vous devez vérifier votre adresse e-mail. Veuillez vérifier en cliquant sur le lien ci-dessous. Une fois l'inscription terminée, une fenêtre de notification apparaîtra confirmant que vos informations d'utilisateur ont été vérifiées. + +URL: $VERIFY_LINK$ + +Si vous avez reçu cet e-mail par erreur, veuillez supprimer cet e-mail de votre système. +Il s'agit d'un e-mail généré automatiquement et cette boîte aux lettres n'est pas surveillée. Merci de ne pas répondre.