Merged PR 646: アカウント情報変更完了通知 [U-112] の実装
## 概要 [Task3308: アカウント情報変更完了通知 [U-112] の実装](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/3308) - アカウント情報変更時の通知メール送信機能を追加しました。 ## レビューポイント - メールに渡す情報の取得内容に不自然な点はないでしょうか? ## UIの変更 - なし ## 動作確認状況 - ローカルで確認
This commit is contained in:
parent
16f743c4c4
commit
3fc184b4af
@ -5561,6 +5561,12 @@ describe('アカウント情報更新', () => {
|
||||
const module = await makeTestingModule(source);
|
||||
if (!module) fail();
|
||||
const service = module.get<AccountsService>(AccountsService);
|
||||
overrideSendgridService(service, {
|
||||
sendMail: async () => {
|
||||
return;
|
||||
},
|
||||
});
|
||||
|
||||
const { tier4Accounts: tier4Accounts } = await makeHierarchicalAccounts(
|
||||
source,
|
||||
);
|
||||
@ -5590,6 +5596,11 @@ describe('アカウント情報更新', () => {
|
||||
const module = await makeTestingModule(source);
|
||||
if (!module) fail();
|
||||
const service = module.get<AccountsService>(AccountsService);
|
||||
overrideSendgridService(service, {
|
||||
sendMail: async () => {
|
||||
return;
|
||||
},
|
||||
});
|
||||
const { tier3Accounts: tier3Accounts, tier4Accounts: tier4Accounts } =
|
||||
await makeHierarchicalAccounts(source);
|
||||
const adduser = await makeTestUser(source, {
|
||||
@ -5619,6 +5630,11 @@ describe('アカウント情報更新', () => {
|
||||
const module = await makeTestingModule(source);
|
||||
if (!module) fail();
|
||||
const service = module.get<AccountsService>(AccountsService);
|
||||
overrideSendgridService(service, {
|
||||
sendMail: async () => {
|
||||
return;
|
||||
},
|
||||
});
|
||||
const { tier4Accounts: tier4Accounts } = await makeHierarchicalAccounts(
|
||||
source,
|
||||
);
|
||||
@ -5649,6 +5665,11 @@ describe('アカウント情報更新', () => {
|
||||
const module = await makeTestingModule(source);
|
||||
if (!module) fail();
|
||||
const service = module.get<AccountsService>(AccountsService);
|
||||
overrideSendgridService(service, {
|
||||
sendMail: async () => {
|
||||
return;
|
||||
},
|
||||
});
|
||||
const { tier4Accounts: tier4Accounts } = await makeHierarchicalAccounts(
|
||||
source,
|
||||
);
|
||||
@ -5676,6 +5697,11 @@ describe('アカウント情報更新', () => {
|
||||
const module = await makeTestingModule(source);
|
||||
if (!module) fail();
|
||||
const service = module.get<AccountsService>(AccountsService);
|
||||
overrideSendgridService(service, {
|
||||
sendMail: async () => {
|
||||
return;
|
||||
},
|
||||
});
|
||||
const { tier4Accounts: tier4Accounts } = await makeHierarchicalAccounts(
|
||||
source,
|
||||
);
|
||||
@ -5702,6 +5728,11 @@ describe('アカウント情報更新', () => {
|
||||
const module = await makeTestingModule(source);
|
||||
if (!module) fail();
|
||||
const service = module.get<AccountsService>(AccountsService);
|
||||
overrideSendgridService(service, {
|
||||
sendMail: async () => {
|
||||
return;
|
||||
},
|
||||
});
|
||||
const { tier4Accounts: tier4Accounts } = await makeHierarchicalAccounts(
|
||||
source,
|
||||
);
|
||||
|
||||
@ -2075,7 +2075,7 @@ export class AccountsService {
|
||||
);
|
||||
|
||||
try {
|
||||
const { account_id: accountId } =
|
||||
const { account_id: accountId, account } =
|
||||
await this.usersRepository.findUserByExternalId(context, externalId);
|
||||
await this.accountRepository.updateAccountInfo(
|
||||
context,
|
||||
@ -2086,6 +2086,52 @@ export class AccountsService {
|
||||
parentAccountId,
|
||||
secondryAdminUserId,
|
||||
);
|
||||
|
||||
// メール送信処理
|
||||
try {
|
||||
if (account === null) {
|
||||
throw new Error(`account not found. accountId: ${accountId}`);
|
||||
}
|
||||
|
||||
let dealerName: string | null = null;
|
||||
if (parentAccountId !== undefined) {
|
||||
const dealer = await this.accountRepository.findAccountById(
|
||||
context,
|
||||
parentAccountId,
|
||||
);
|
||||
dealerName = dealer.company_name;
|
||||
}
|
||||
|
||||
const { external_id: externalId } =
|
||||
await this.usersRepository.findUserById(context, primaryAdminUserId);
|
||||
|
||||
const primaryAdmin = await this.adB2cService.getUser(
|
||||
context,
|
||||
externalId,
|
||||
);
|
||||
|
||||
const {
|
||||
displayName: primaryAdminName,
|
||||
emailAddress: primaryAdminEmail,
|
||||
} = getUserNameAndMailAddress(primaryAdmin);
|
||||
|
||||
if (!primaryAdminEmail) {
|
||||
throw new Error(
|
||||
`adb2c user mail not found. externalId: ${externalId}`,
|
||||
);
|
||||
}
|
||||
|
||||
await this.sendgridService.sendMailWithU112(
|
||||
context,
|
||||
primaryAdminName,
|
||||
primaryAdminEmail,
|
||||
account.company_name,
|
||||
dealerName,
|
||||
);
|
||||
} catch (e) {
|
||||
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
|
||||
// メール送信に関する例外はログだけ出して握りつぶす
|
||||
}
|
||||
} catch (e) {
|
||||
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
|
||||
if (e instanceof Error) {
|
||||
|
||||
@ -42,6 +42,11 @@ export class SendGridService {
|
||||
private readonly templateU109Text: string;
|
||||
private readonly templateU111Html: string;
|
||||
private readonly templateU111Text: string;
|
||||
private readonly templateU112Html: string;
|
||||
private readonly templateU112Text: string;
|
||||
// U-112のテンプレート差分(親アカウントがない場合)
|
||||
private readonly templateU112NoParentHtml: string;
|
||||
private readonly templateU112NoParentText: string;
|
||||
private readonly templateU117Html: string;
|
||||
private readonly templateU117Text: string;
|
||||
|
||||
@ -127,6 +132,26 @@ export class SendGridService {
|
||||
'utf-8',
|
||||
);
|
||||
|
||||
this.templateU112Html = readFileSync(
|
||||
path.resolve(__dirname, `../../templates/template_U_112.html`),
|
||||
'utf-8',
|
||||
);
|
||||
this.templateU112Text = readFileSync(
|
||||
path.resolve(__dirname, `../../templates/template_U_112.txt`),
|
||||
'utf-8',
|
||||
);
|
||||
this.templateU112NoParentHtml = readFileSync(
|
||||
path.resolve(
|
||||
__dirname,
|
||||
`../../templates/template_U_112_no_parent.html`,
|
||||
),
|
||||
'utf-8',
|
||||
);
|
||||
this.templateU112NoParentText = readFileSync(
|
||||
path.resolve(__dirname, `../../templates/template_U_112_no_parent.txt`),
|
||||
'utf-8',
|
||||
);
|
||||
|
||||
this.templateU117Html = readFileSync(
|
||||
path.resolve(__dirname, `../../templates/template_U_117.html`),
|
||||
'utf-8',
|
||||
@ -602,6 +627,72 @@ export class SendGridService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* U-112のテンプレートを使用したメールを送信する
|
||||
* @param context
|
||||
* @param primaryAdminName 情報変更を行ったアカウントの管理者(primary)の名前
|
||||
* @param primaryAdminMail 情報変更を行ったアカウントの管理者(primary)のメールアドレス
|
||||
* @param customerAccountName 情報変更を行ったアカウントの名前
|
||||
* @param dealerAccountName 問題発生時に問い合わせする先の上位のディーラー名(会社名)
|
||||
* @returns mail with u112
|
||||
*/
|
||||
async sendMailWithU112(
|
||||
context: Context,
|
||||
primaryAdminName: string,
|
||||
primaryAdminMail: string,
|
||||
customerAccountName: string,
|
||||
dealerAccountName: string | null,
|
||||
): Promise<void> {
|
||||
this.logger.log(
|
||||
`[IN] [${context.getTrackingId()}] ${this.sendMailWithU112.name}`,
|
||||
);
|
||||
try {
|
||||
const subject = 'Account Edit Notification [U-112]';
|
||||
|
||||
let html: string;
|
||||
let text: string;
|
||||
|
||||
// 親アカウントがない場合は別のテンプレートを使用する
|
||||
if (dealerAccountName === null) {
|
||||
// メールの本文を作成する
|
||||
html = this.templateU112NoParentHtml
|
||||
.replaceAll(CUSTOMER_NAME, customerAccountName)
|
||||
.replaceAll(PRIMARY_ADMIN_NAME, primaryAdminName)
|
||||
.replaceAll(TOP_URL, this.appDomain);
|
||||
text = this.templateU112NoParentText
|
||||
.replaceAll(CUSTOMER_NAME, customerAccountName)
|
||||
.replaceAll(PRIMARY_ADMIN_NAME, primaryAdminName)
|
||||
.replaceAll(TOP_URL, this.appDomain);
|
||||
} else {
|
||||
html = this.templateU112Html
|
||||
.replaceAll(CUSTOMER_NAME, customerAccountName)
|
||||
.replaceAll(DEALER_NAME, dealerAccountName)
|
||||
.replaceAll(PRIMARY_ADMIN_NAME, primaryAdminName)
|
||||
.replaceAll(TOP_URL, this.appDomain);
|
||||
text = this.templateU112Text
|
||||
.replaceAll(CUSTOMER_NAME, customerAccountName)
|
||||
.replaceAll(DEALER_NAME, dealerAccountName)
|
||||
.replaceAll(PRIMARY_ADMIN_NAME, primaryAdminName)
|
||||
.replaceAll(TOP_URL, this.appDomain);
|
||||
}
|
||||
|
||||
// メールを送信する
|
||||
this.sendMail(
|
||||
context,
|
||||
[primaryAdminMail],
|
||||
[],
|
||||
this.mailFrom,
|
||||
subject,
|
||||
text,
|
||||
html,
|
||||
);
|
||||
} finally {
|
||||
this.logger.log(
|
||||
`[OUT] [${context.getTrackingId()}] ${this.sendMailWithU112.name}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* U-117のテンプレートを使用したメールを送信する
|
||||
* @param context
|
||||
|
||||
66
dictation_server/src/templates/template_U_112.html
Normal file
66
dictation_server/src/templates/template_U_112.html
Normal file
@ -0,0 +1,66 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Account Edit Notification [U-112]</title>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<h3><English></h3>
|
||||
<p>Dear $CUSTOMER_NAME$, -> $PRIMARY_ADMIN_NAME$</p>
|
||||
<p>
|
||||
Your account information has been edited successfully. To check or
|
||||
change your company's account information, please log in to ODMS
|
||||
Cloud.<br />
|
||||
URL: $TOP_URL$
|
||||
</p>
|
||||
<p>
|
||||
If you need support regarding ODMS Cloud, please contact $DEALER_NAME$.
|
||||
</p>
|
||||
<p>
|
||||
If you have received this e-mail in error, please delete this e-mail
|
||||
from your system.<br />
|
||||
This is an automatically generated e-mail and this mailbox is not
|
||||
monitored. Please do not reply.
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<h3><Deutsch></h3>
|
||||
<p>Sehr geehrte(r) $CUSTOMER_NAME$, -> $PRIMARY_ADMIN_NAME$</p>
|
||||
<p>
|
||||
Ihre Kontoinformationen wurden erfolgreich bearbeitet. Um die
|
||||
Kontoinformationen Ihres Unternehmens zu überprüfen oder zu ändern,
|
||||
melden Sie sich bitte bei ODMS Cloud an.<br />
|
||||
URL: $TOP_URL$
|
||||
</p>
|
||||
<p>
|
||||
Wenn Sie Unterstützung bezüglich ODMS Cloud benötigen, wenden Sie sich
|
||||
bitte an $DEALER_NAME$.
|
||||
</p>
|
||||
<p>
|
||||
Wenn Sie diese E-Mail fälschlicherweise erhalten haben, löschen Sie
|
||||
diese E-Mail bitte aus Ihrem System.<br />
|
||||
Dies ist eine automatisch generierte E-Mail und dieses Postfach wird
|
||||
nicht überwacht. Bitte nicht antworten.
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<h3><Français></h3>
|
||||
<p>Chère/Cher $CUSTOMER_NAME$, -> $PRIMARY_ADMIN_NAME$</p>
|
||||
<p>
|
||||
Les informations de votre compte ont été modifiées avec succès. Pour
|
||||
vérifier ou modifier les informations du compte de votre entreprise,
|
||||
veuillez vous connecter à ODMS Cloud.<br />
|
||||
URL: $TOP_URL$
|
||||
</p>
|
||||
<p>
|
||||
Si vous avez besoin d'assistance concernant ODMS Cloud, veuillez
|
||||
contacter $DEALER_NAME$.
|
||||
</p>
|
||||
<p>
|
||||
Si vous avez reçu cet e-mail par erreur, veuillez supprimer cet e-mail
|
||||
de votre système.<br />
|
||||
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.
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
35
dictation_server/src/templates/template_U_112.txt
Normal file
35
dictation_server/src/templates/template_U_112.txt
Normal file
@ -0,0 +1,35 @@
|
||||
<English>
|
||||
|
||||
Dear $CUSTOMER_NAME$, -> $PRIMARY_ADMIN_NAME$
|
||||
|
||||
Your account information has been edited successfully. To check or change your company's account information, please log in to ODMS Cloud.
|
||||
URL: $TOP_URL$
|
||||
|
||||
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>
|
||||
|
||||
Sehr geehrte(r) $CUSTOMER_NAME$, -> $PRIMARY_ADMIN_NAME$
|
||||
|
||||
Ihre Kontoinformationen wurden erfolgreich bearbeitet. Um die Kontoinformationen Ihres Unternehmens zu überprüfen oder zu ändern, melden Sie sich bitte bei ODMS Cloud an.
|
||||
URL: $TOP_URL$
|
||||
|
||||
Wenn Sie Unterstützung bezüglich ODMS Cloud benötigen, wenden Sie sich bitte an $DEALER_NAME$.
|
||||
|
||||
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>
|
||||
|
||||
Chère/Cher $CUSTOMER_NAME$, -> $PRIMARY_ADMIN_NAME$
|
||||
|
||||
Les informations de votre compte ont été modifiées avec succès. Pour vérifier ou modifier les informations du compte de votre entreprise, veuillez vous connecter à ODMS Cloud.
|
||||
URL: $TOP_URL$
|
||||
|
||||
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.
|
||||
55
dictation_server/src/templates/template_U_112_no_parent.html
Normal file
55
dictation_server/src/templates/template_U_112_no_parent.html
Normal file
@ -0,0 +1,55 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Account Edit Notification [U-112]</title>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<h3><English></h3>
|
||||
<p>Dear $CUSTOMER_NAME$, -> $PRIMARY_ADMIN_NAME$</p>
|
||||
<p>
|
||||
Your account information has been edited successfully. To check or
|
||||
change your company's account information, please log in to ODMS
|
||||
Cloud.<br />
|
||||
URL: $TOP_URL$
|
||||
</p>
|
||||
<p>
|
||||
If you have received this e-mail in error, please delete this e-mail
|
||||
from your system.<br />
|
||||
This is an automatically generated e-mail and this mailbox is not
|
||||
monitored. Please do not reply.
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<h3><Deutsch></h3>
|
||||
<p>Sehr geehrte(r) $CUSTOMER_NAME$, -> $PRIMARY_ADMIN_NAME$</p>
|
||||
<p>
|
||||
Ihre Kontoinformationen wurden erfolgreich bearbeitet. Um die
|
||||
Kontoinformationen Ihres Unternehmens zu überprüfen oder zu ändern,
|
||||
melden Sie sich bitte bei ODMS Cloud an.<br />
|
||||
URL: $TOP_URL$
|
||||
</p>
|
||||
<p>
|
||||
Wenn Sie diese E-Mail fälschlicherweise erhalten haben, löschen Sie
|
||||
diese E-Mail bitte aus Ihrem System.<br />
|
||||
Dies ist eine automatisch generierte E-Mail und dieses Postfach wird
|
||||
nicht überwacht. Bitte nicht antworten.
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<h3><Français></h3>
|
||||
<p>Chère/Cher $CUSTOMER_NAME$, -> $PRIMARY_ADMIN_NAME$</p>
|
||||
<p>
|
||||
Les informations de votre compte ont été modifiées avec succès. Pour
|
||||
vérifier ou modifier les informations du compte de votre entreprise,
|
||||
veuillez vous connecter à ODMS Cloud.<br />
|
||||
URL: $TOP_URL$
|
||||
</p>
|
||||
<p>
|
||||
Si vous avez reçu cet e-mail par erreur, veuillez supprimer cet e-mail
|
||||
de votre système.<br />
|
||||
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.
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
29
dictation_server/src/templates/template_U_112_no_parent.txt
Normal file
29
dictation_server/src/templates/template_U_112_no_parent.txt
Normal file
@ -0,0 +1,29 @@
|
||||
<English>
|
||||
|
||||
Dear $CUSTOMER_NAME$, -> $PRIMARY_ADMIN_NAME$
|
||||
|
||||
Your account information has been edited successfully. To check or change your company's account information, please log in to ODMS Cloud.
|
||||
URL: $TOP_URL$
|
||||
|
||||
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>
|
||||
|
||||
Sehr geehrte(r) $CUSTOMER_NAME$, -> $PRIMARY_ADMIN_NAME$
|
||||
|
||||
Ihre Kontoinformationen wurden erfolgreich bearbeitet. Um die Kontoinformationen Ihres Unternehmens zu überprüfen oder zu ändern, melden Sie sich bitte bei ODMS Cloud an.
|
||||
URL: $TOP_URL$
|
||||
|
||||
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>
|
||||
|
||||
Chère/Cher $CUSTOMER_NAME$, -> $PRIMARY_ADMIN_NAME$
|
||||
|
||||
Les informations de votre compte ont été modifiées avec succès. Pour vérifier ou modifier les informations du compte de votre entreprise, veuillez vous connecter à ODMS Cloud.
|
||||
URL: $TOP_URL$
|
||||
|
||||
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.
|
||||
Loading…
x
Reference in New Issue
Block a user