Merged PR 663: develop不具合対応

## 概要
[Task3404: develop不具合対応](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/3404)

- ライセンス割り当て通知メールのTOにAdminが入るように修正しました。
- 不要なメソッド`createMailContentFromEmailConfirm`を削除しました。

## レビューポイント
- 共有

## UIの変更
- なし

## 動作確認状況
- ローカルで確認
This commit is contained in:
makabe.t 2023-12-26 07:24:10 +00:00
parent f2ef2228c3
commit 6f62a016d4
6 changed files with 9 additions and 149 deletions

View File

@ -80,12 +80,6 @@ export const overrideAdB2cService = <TService>(
export const overrideSendgridService = <TService>(
service: TService,
overrides: {
createMailContentFromEmailConfirm?: (
context: Context,
accountId: number,
userId: number,
email: string,
) => Promise<{ subject: string; text: string; html: string }>;
createMailContentFromEmailConfirmForNormalUser?: (
accountId: number,
userId: number,
@ -119,12 +113,6 @@ export const overrideSendgridService = <TService>(
writable: true,
});
}
if (overrides.createMailContentFromEmailConfirm) {
Object.defineProperty(obj, obj.createMailContentFromEmailConfirm.name, {
value: overrides.createMailContentFromEmailConfirm,
writable: true,
});
}
if (overrides.createMailContentFromEmailConfirmForNormalUser) {
Object.defineProperty(

View File

@ -121,14 +121,7 @@ describe('createAccount', () => {
},
});
overrideSendgridService(service, {
sendMail: async () => {
return;
},
createMailContentFromEmailConfirm: async () => {
return { html: '', text: '', subject: '' };
},
});
overrideSendgridService(service, {});
overrideBlobstorageService(service, {
createContainer: async () => {
return;
@ -183,14 +176,7 @@ describe('createAccount', () => {
},
});
overrideSendgridService(service, {
sendMail: async () => {
return;
},
createMailContentFromEmailConfirm: async () => {
return { html: '', text: '', subject: '' };
},
});
overrideSendgridService(service, {});
const companyName = 'test_company_name';
const country = 'US';
@ -254,14 +240,7 @@ describe('createAccount', () => {
},
});
overrideSendgridService(service, {
sendMail: async () => {
return;
},
createMailContentFromEmailConfirm: async () => {
return { html: '', text: '', subject: '' };
},
});
overrideSendgridService(service, {});
const companyName = 'test_company_name';
const country = 'US';
@ -632,13 +611,6 @@ describe('createAccount', () => {
sendMail: async () => {
throw new Error();
},
createMailContentFromEmailConfirm: async () => {
return {
html: 'dummy_html',
subject: 'dummy_subject',
text: 'dummy_text',
};
},
});
overrideBlobstorageService(service, {
createContainer: async () => {
@ -721,13 +693,6 @@ describe('createAccount', () => {
sendMail: async () => {
throw new Error();
},
createMailContentFromEmailConfirm: async () => {
return {
html: 'dummy_html',
subject: 'dummy_subject',
text: 'dummy_text',
};
},
});
overrideBlobstorageService(service, {
createContainer: async () => {

View File

@ -44,11 +44,6 @@ export type AdB2cMockValue = {
getUsers: AdB2cUser[] | Error;
};
export type SendGridMockValue = {
createMailContentFromEmailConfirm: {
subject: string;
text: string;
html: string;
};
createMailContentFromEmailConfirmForNormalUser: {
subject: string;
text: string;
@ -242,20 +237,8 @@ export const makeConfigMock = (value: ConfigMockValue) => {
};
};
export const makeSendGridServiceMock = (value: SendGridMockValue) => {
const {
createMailContentFromEmailConfirm,
createMailContentFromEmailConfirmForNormalUser,
sendMail,
} = value;
const { createMailContentFromEmailConfirmForNormalUser, sendMail } = value;
return {
createMailContentFromEmailConfirm:
createMailContentFromEmailConfirm instanceof Error
? jest
.fn<Promise<void>, []>()
.mockRejectedValue(createMailContentFromEmailConfirm)
: jest
.fn<Promise<{ subject: string; text: string; html: string }>, []>()
.mockResolvedValue(createMailContentFromEmailConfirm),
createMailContentFromEmailConfirmForNormalUser:
createMailContentFromEmailConfirmForNormalUser instanceof Error
? jest
@ -475,7 +458,6 @@ export const makeDefaultAdB2cMockValue = (): AdB2cMockValue => {
export const makeDefaultSendGridlValue = (): SendGridMockValue => {
return {
sendMail: undefined,
createMailContentFromEmailConfirm: { subject: '', text: '', html: '' },
createMailContentFromEmailConfirmForNormalUser: {
subject: 'Verify your new account',
text: `The verification URL.`,

View File

@ -48,11 +48,6 @@ export type AdB2cMockValue = {
};
export type SendGridMockValue = {
createMailContentFromEmailConfirm: {
subject: string;
text: string;
html: string;
};
createMailContentFromEmailConfirmForNormalUser:
| { subject: string; text: string; html: string }
| Error;
@ -135,16 +130,8 @@ export const makeSortCriteriaRepositoryMock = (
};
export const makeSendGridServiceMock = (value: SendGridMockValue) => {
const { createMailContentFromEmailConfirm, sendMail } = value;
const { sendMail } = value;
return {
createMailContentFromEmailConfirm:
createMailContentFromEmailConfirm instanceof Error
? jest
.fn<Promise<void>, []>()
.mockRejectedValue(createMailContentFromEmailConfirm)
: jest
.fn<Promise<{ subject: string; text: string; html: string }>, []>()
.mockResolvedValue(createMailContentFromEmailConfirm),
sendMail:
sendMail instanceof Error
? jest.fn<Promise<void>, []>().mockRejectedValue(sendMail)
@ -291,7 +278,6 @@ export const makeConfigMock = (value: ConfigMockValue) => {
export const makeDefaultSendGridlValue = (): SendGridMockValue => {
return {
sendMail: undefined,
createMailContentFromEmailConfirm: { subject: '', text: '', html: '' },
createMailContentFromEmailConfirmForNormalUser: {
subject: 'test',
text: 'test',

View File

@ -1105,14 +1105,11 @@ export class UsersService {
throw new Error(`emailAddress is null. externalId=${externalId}`);
}
// 管理者に割り当てた場合にはTOに管理者のメールアドレスを設定するので、CCには管理者のメールアドレスを設定しない
const ccAdminEmails = adminEmails.filter((x) => x !== emailAddress);
await this.sendgridService.sendMailWithU108(
context,
displayName,
emailAddress,
ccAdminEmails,
adminEmails,
companyName,
dealerName,
);

View File

@ -205,66 +205,6 @@ export class SendGridService {
}
}
/**
* Email認証用のメールコンテンツを作成する
* @param accountId ID
* @param userId ID
* @param email
* @returns
*/
async createMailContentFromEmailConfirm(
context: Context,
accountId: number,
userId: number,
email: string,
): Promise<{ subject: string; text: string; html: string }> {
this.logger.log(
`[IN] [${context.getTrackingId()}] ${
this.createMailContentFromEmailConfirm.name
} | params: { ` +
`accountId: ${accountId},` +
`userId: ${userId} };`,
);
try {
const privateKey = getPrivateKey(this.configService);
const token = sign<{ accountId: number; userId: number; email: string }>(
{
accountId,
userId,
email,
},
this.emailConfirmLifetime,
privateKey,
);
const path = 'mail-confirm/';
const html = this.templateEmailVerifyHtml
.replace('VERIFY_LINK', `${this.appDomain}${path}?verify=${token}`)
.replace(
'VERIFY_LINK_TEXT',
`${this.appDomain}${path}?verify=${token}`,
);
const text = this.templateEmailVerifyText
.replace('VERIFY_LINK', `${this.appDomain}${path}?verify=${token}`)
.replace(
'VERIFY_LINK_TEXT',
`${this.appDomain}${path}?verify=${token}`,
);
return {
subject: 'Verify your new account',
text: text,
html: html,
};
} finally {
this.logger.log(
`[OUT] [${context.getTrackingId()}] ${
this.createMailContentFromEmailConfirm.name
}`,
);
}
}
/**
* Email認証用のメールコンテンツを作成する()
* @param accountId ID
@ -655,11 +595,13 @@ export class SendGridService {
.replaceAll(USER_EMAIL, userMail)
.replaceAll(TOP_URL, this.appDomain);
const ccAddress = customerAdminMails.includes(userMail) ? [] : [userMail];
// メールを送信する
this.sendMail(
context,
[userMail],
customerAdminMails,
ccAddress,
this.mailFrom,
subject,
text,