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.