diff --git a/dictation_client/.vscode/settings.json b/dictation_client/.vscode/settings.json index 4ec4dc1..2f24e82 100644 --- a/dictation_client/.vscode/settings.json +++ b/dictation_client/.vscode/settings.json @@ -27,8 +27,8 @@ "debug.javascript.usePreview": false, "editor.copyWithSyntaxHighlighting": false, "editor.codeActionsOnSave": { - "source.fixAll.eslint": true, - "source.fixAll.stylelint": true + "source.fixAll.eslint": "explicit", + "source.fixAll.stylelint": "explicit" }, "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.formatOnSave": true, diff --git a/dictation_server/.vscode/settings.json b/dictation_server/.vscode/settings.json index 1f6f864..8edcbd3 100644 --- a/dictation_server/.vscode/settings.json +++ b/dictation_server/.vscode/settings.json @@ -1,7 +1,7 @@ { "terminal.integrated.shell.linux": "/bin/bash", "editor.codeActionsOnSave": { - "source.fixAll.eslint": true + "source.fixAll.eslint": "explicit" }, "eslint.format.enable": false, "[javascript]": { diff --git a/dictation_server/src/features/licenses/licenses.service.ts b/dictation_server/src/features/licenses/licenses.service.ts index 5e981df..5b5ef19 100644 --- a/dictation_server/src/features/licenses/licenses.service.ts +++ b/dictation_server/src/features/licenses/licenses.service.ts @@ -106,6 +106,28 @@ export class LicensesService { parentAccountId, orderCount, ); + + // メール送信処理 + try { + const customer = await this.getAccountInformation(context, myAccountId); + const dealer = await this.getAccountInformation( + context, + parentAccountId, + ); + + this.sendgridService.sendMailWithU105( + context, + customer.adminEmails, + customer.companyName, + orderCount, + poNumber, + dealer.adminEmails, + dealer.companyName, + ); + } catch (e) { + this.logger.error(`[${context.getTrackingId()}] error=${e}`); + // メール送信に関する例外はログだけ出して握りつぶす + } } catch (e) { switch (e.constructor) { case PoNumberAlreadyExistError: @@ -331,7 +353,11 @@ export class LicensesService { await this.usersRepository.findUserByExternalId(context, externalId) ).account_id; // 注文キャンセル処理 - const { canceledOrderId } = await this.licensesRepository.cancelOrder(context, myAccountId, poNumber); + const { canceledOrderId } = await this.licensesRepository.cancelOrder( + context, + myAccountId, + poNumber, + ); // メール送信処理 try { @@ -366,7 +392,7 @@ export class LicensesService { context, customerAccountId, poNumber, - canceledOrderId + canceledOrderId, ); if (order == null) { diff --git a/dictation_server/src/gateways/sendgrid/sendgrid.service.ts b/dictation_server/src/gateways/sendgrid/sendgrid.service.ts index 30bb16a..5b1fb5a 100644 --- a/dictation_server/src/gateways/sendgrid/sendgrid.service.ts +++ b/dictation_server/src/gateways/sendgrid/sendgrid.service.ts @@ -21,6 +21,8 @@ export class SendGridService { private readonly mailFrom: string; private readonly templateEmailVerifyHtml: string; private readonly templateEmailVerifyText: string; + private readonly templateU105Html: string; + private readonly templateU105Text: string; private readonly templateU106Html: string; private readonly templateU106Text: string; @@ -44,6 +46,15 @@ export class SendGridService { 'utf-8', ); + this.templateU105Html = readFileSync( + path.resolve(__dirname, `../../templates/template_U_105.html`), + 'utf-8', + ); + this.templateU105Text = readFileSync( + path.resolve(__dirname, `../../templates/template_U_105.txt`), + 'utf-8', + ); + this.templateU106Html = readFileSync( path.resolve(__dirname, `../../templates/template_U_106.html`), 'utf-8', @@ -156,6 +167,61 @@ export class SendGridService { }; } + /** + * U-105のテンプレートを使用したメールを送信する + * @param context + * @param customerMails 注文を行ったアカウントの管理者(primary/secondary)のメールアドレス + * @param customerAccountName 送信対象の企業名 + * @param lisenceCount 注文を行った対象の注文の内容(ライセンス数) + * @param poNumber 注文を行った対象の注文の内容(PO番号) + * @param dealerEmails 問題発生時に問い合わせする先の上位のディーラーの管理者(primary/secondary)のメールアドレス + * @param dealerAccountName 問題発生時に問い合わせする先の上位のディーラー名(会社名) + * @returns mail with u105 + */ + async sendMailWithU105( + context: Context, + customerMails: string[], + customerAccountName: string, + lisenceCount: number, + poNumber: string, + dealerEmails: string[], + dealerAccountName: string, + ): Promise { + this.logger.log( + `[IN] [${context.getTrackingId()}] ${this.sendMailWithU105.name}`, + ); + try { + const subject = 'License Requested Notification [U-105]'; + + // メールの本文を作成する + const html = this.templateU105Html + .replaceAll(CUSTOMER_NAME, customerAccountName) + .replaceAll(DEALER_NAME, dealerAccountName) + .replaceAll(PO_NUMBER, poNumber) + .replaceAll(LICENSE_QUANTITY, `${lisenceCount}`); + const text = this.templateU105Text + .replaceAll(CUSTOMER_NAME, customerAccountName) + .replaceAll(DEALER_NAME, dealerAccountName) + .replaceAll(PO_NUMBER, poNumber) + .replaceAll(LICENSE_QUANTITY, `${lisenceCount}`); + + // メールを送信する + this.sendMail( + context, + customerMails, + dealerEmails, + this.mailFrom, + subject, + text, + html, + ); + } finally { + this.logger.log( + `[OUT] [${context.getTrackingId()}] ${this.sendMailWithU105.name}`, + ); + } + } + /** * U-106のテンプレートを使用したメールを送信する * @param context @@ -184,23 +250,15 @@ export class SendGridService { // メールの本文を作成する const html = this.templateU106Html - .split(CUSTOMER_NAME) - .join(customerAccountName) - .split(DEALER_NAME) - .join(dealerAccountName) - .split(PO_NUMBER) - .join(poNumber) - .split(LICENSE_QUANTITY) - .join(`${lisenceCount}`); + .replaceAll(CUSTOMER_NAME, customerAccountName) + .replaceAll(DEALER_NAME, dealerAccountName) + .replaceAll(PO_NUMBER, poNumber) + .replaceAll(LICENSE_QUANTITY, `${lisenceCount}`); const text = this.templateU106Text - .split(CUSTOMER_NAME) - .join(customerAccountName) - .split(DEALER_NAME) - .join(dealerAccountName) - .split(PO_NUMBER) - .join(poNumber) - .split(LICENSE_QUANTITY) - .join(`${lisenceCount}`); + .replaceAll(CUSTOMER_NAME, customerAccountName) + .replaceAll(DEALER_NAME, dealerAccountName) + .replaceAll(PO_NUMBER, poNumber) + .replaceAll(LICENSE_QUANTITY, `${lisenceCount}`); // メールを送信する this.sendMail( diff --git a/dictation_server/src/templates/template_U_105.html b/dictation_server/src/templates/template_U_105.html new file mode 100644 index 0000000..f71ac41 --- /dev/null +++ b/dictation_server/src/templates/template_U_105.html @@ -0,0 +1,93 @@ + + + License Requested Notification [U-105] + + +
+

<English>

+

Dear $CUSTOMER_NAME$,

+

+ We have received your requested license order.
+ - Number of licenses ordered: $LICENSE_QUANTITY$
+ - PO Number: $PO_NUMBER$ +

+

+ Licenses will be issued by your $DEALER_NAME$ which you have selected in + the setting. Licenses issued by your dealer will be stored in your + license inventory. Please log in to the ODMS Cloud to view and assign + licenses to your users. +

+

+ Licenses are valid for 12 months from the date they are assigned to a + user. +

+

+ If you need support regarding ODMS Cloud, please contact $DEALER_NAME$. +

+

+ 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>

+

Dear $CUSTOMER_NAME$,

+

+ We have received your requested license order.
+ - Number of licenses ordered: $LICENSE_QUANTITY$
+ - PO Number: $PO_NUMBER$ +

+

+ Licenses will be issued by your $DEALER_NAME$ which you have selected in + the setting. Licenses issued by your dealer will be stored in your + license inventory. Please log in to the ODMS Cloud to view and assign + licenses to your users. +

+

+ Licenses are valid for 12 months from the date they are assigned to a + user. +

+

+ If you need support regarding ODMS Cloud, please contact $DEALER_NAME$. +

+

+ 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. +

+
+
+

<Français>

+

Chère/Cher $CUSTOMER_NAME$,

+

+ Nous avons reçu votre commande de licence demandée.
+ - Nombre de licences commandées: $LICENSE_QUANTITY$
+ - Numéro de bon de commande: $PO_NUMBER$ +

+

+ Les licences seront délivrées par votre $DEALER_NAME$ que vous avez + sélectionné dans les paramètres. Les licences délivrées par votre + concessionnaire seront stockées dans votre inventaire de licences. + Veuillez vous connecter au ODMS Cloud pour afficher et attribuer des + licences à vos utilisateurs. +

+

+ Les licences sont valables 12 mois à compter de la date à laquelle elles + sont attribuées à un utilisateur. +

+

+ Si vous avez besoin d'assistance concernant ODMS Cloud, veuillez + contacter $DEALER_NAME$. +

+

+ 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_105.txt b/dictation_server/src/templates/template_U_105.txt new file mode 100644 index 0000000..1fa5b81 --- /dev/null +++ b/dictation_server/src/templates/template_U_105.txt @@ -0,0 +1,50 @@ + + +Dear $CUSTOMER_NAME$, + +We have received your requested license order. + - Number of licenses ordered: $LICENSE_QUANTITY$ + - PO Number: $PO_NUMBER$ + +Licenses will be issued by your $DEALER_NAME$ which you have selected in the setting. Licenses issued by your dealer will be stored in your license inventory. Please log in to the ODMS Cloud to view and assign licenses to your users. + +Licenses are valid for 12 months from the date they are assigned to a user. + +If you need support regarding ODMS Cloud, please contact $DEALER_NAME$. + +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. + + + +Dear $CUSTOMER_NAME$, + +We have received your requested license order. + - Number of licenses ordered: $LICENSE_QUANTITY$ + - PO Number: $PO_NUMBER$ + +Licenses will be issued by your $DEALER_NAME$ which you have selected in the setting. Licenses issued by your dealer will be stored in your license inventory. Please log in to the ODMS Cloud to view and assign licenses to your users. + +Licenses are valid for 12 months from the date they are assigned to a user. + +If you need support regarding ODMS Cloud, please contact $DEALER_NAME$. + +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. + + + +Chère/Cher $CUSTOMER_NAME$, + +Nous avons reçu votre commande de licence demandée. + - Nombre de licences commandées: $LICENSE_QUANTITY$ + - Numéro de bon de commande: $PO_NUMBER$ + +Les licences seront délivrées par votre $DEALER_NAME$ que vous avez sélectionné dans les paramètres. Les licences délivrées par votre concessionnaire seront stockées dans votre inventaire de licences. Veuillez vous connecter au ODMS Cloud pour afficher et attribuer des licences à vos utilisateurs. + +Les licences sont valables 12 mois à compter de la date à laquelle elles sont attribuées à un utilisateur. + +Si vous avez besoin d'assistance concernant ODMS Cloud, veuillez contacter $DEALER_NAME$. + +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/tsconfig.json b/dictation_server/tsconfig.json index 8b9d137..4da464e 100644 --- a/dictation_server/tsconfig.json +++ b/dictation_server/tsconfig.json @@ -6,7 +6,7 @@ "emitDecoratorMetadata": true, "experimentalDecorators": true, "allowSyntheticDefaultImports": true, - "target": "es2017", + "target": "ES2021", "sourceMap": true, "outDir": "./dist", "baseUrl": "./",