diff --git a/dictation_function/src/entity/account.entity.ts b/dictation_function/src/entity/account.entity.ts index 3a1c9af..15988a6 100644 --- a/dictation_function/src/entity/account.entity.ts +++ b/dictation_function/src/entity/account.entity.ts @@ -49,7 +49,7 @@ export class Account { @Column({ nullable: true, type: "datetime" }) deleted_at: Date | null; - @Column({ nullable: true, type: "datetime" }) + @Column({ nullable: true, type: "varchar" }) created_by: string | null; @CreateDateColumn({ @@ -58,7 +58,7 @@ export class Account { }) // defaultはSQLite用設定値.本番用は別途migrationで設定 created_at: Date; - @Column({ nullable: true, type: "datetime" }) + @Column({ nullable: true, type: "varchar"}) updated_by: string | null; @UpdateDateColumn({ diff --git a/dictation_function/src/entity/license.entity.ts b/dictation_function/src/entity/license.entity.ts index 56f2f00..ca38f5a 100644 --- a/dictation_function/src/entity/license.entity.ts +++ b/dictation_function/src/entity/license.entity.ts @@ -40,7 +40,7 @@ export class License { @Column({ nullable: true, type: "bigint", transformer: bigintTransformer }) delete_order_id: number | null; - @Column({ nullable: true, type: "datetime" }) + @Column({ nullable: true, type: "varchar" }) created_by: string | null; @CreateDateColumn({ @@ -49,7 +49,7 @@ export class License { }) created_at: Date; - @Column({ nullable: true, type: "datetime" }) + @Column({ nullable: true, type: "varchar" }) updated_by: string | null; @UpdateDateColumn({ @@ -89,7 +89,7 @@ export class LicenseAllocationHistory { @Column({ nullable: true, type: "datetime" }) deleted_at: Date | null; - @Column({ nullable: true, type: "datetime" }) + @Column({ nullable: true, type: "varchar" }) created_by: string | null; @CreateDateColumn({ @@ -98,7 +98,7 @@ export class LicenseAllocationHistory { }) created_at: Date; - @Column({ nullable: true, type: "datetime" }) + @Column({ nullable: true, type: "varchar" }) updated_by: string | null; @UpdateDateColumn({ diff --git a/dictation_function/src/entity/user.entity.ts b/dictation_function/src/entity/user.entity.ts index 10032d4..d8c78f9 100644 --- a/dictation_function/src/entity/user.entity.ts +++ b/dictation_function/src/entity/user.entity.ts @@ -31,6 +31,9 @@ export class User { @Column({ nullable: true, type: "varchar" }) accepted_eula_version: string | null; + @Column({ nullable: true, type: "varchar" }) + accepted_privacy_notice_version: string | null; + @Column({ nullable: true, type: "varchar" }) accepted_dpa_version: string | null; @@ -55,7 +58,7 @@ export class User { @Column({ nullable: true, type: "datetime" }) deleted_at: Date | null; - @Column({ nullable: true, type: "datetime" }) + @Column({ nullable: true, type: "varchar" }) created_by: string | null; @CreateDateColumn({ @@ -64,7 +67,7 @@ export class User { }) // defaultはSQLite用設定値.本番用は別途migrationで設定 created_at: Date; - @Column({ nullable: true, type: "datetime" }) + @Column({ nullable: true, type: "varchar" }) updated_by: string | null; @UpdateDateColumn({ diff --git a/dictation_function/src/functions/licenseAlert.ts b/dictation_function/src/functions/licenseAlert.ts index ad4119f..b3735fc 100644 --- a/dictation_function/src/functions/licenseAlert.ts +++ b/dictation_function/src/functions/licenseAlert.ts @@ -167,9 +167,16 @@ async function getAlertMailTargetAccount( // 第五のアカウントを取得 const accountRepository = datasource.getRepository(Account); + // 管理者ユーザーが規約に同意しているアカウントのみを取得 + // プロダクト バックログ項目 4073: [保守]システムに一度もログインしていないユーザーにはライセンスアラートメールを送信しないようにしたい の対応 const accounts = await accountRepository.find({ where: { tier: TIERS.TIER5, + primaryAdminUser: { + accepted_dpa_version: Not(IsNull()), + accepted_eula_version: Not(IsNull()), + accepted_privacy_notice_version: Not(IsNull()), + }, }, relations: { primaryAdminUser: true, diff --git a/dictation_function/src/test/common/utility.ts b/dictation_function/src/test/common/utility.ts index f675ed7..3db9a67 100644 --- a/dictation_function/src/test/common/utility.ts +++ b/dictation_function/src/test/common/utility.ts @@ -96,7 +96,7 @@ export const makeTestAccount = async ( locked: d?.locked ?? false, company_name: d?.company_name ?? "test inc.", verified: d?.verified ?? true, - deleted_at: d?.deleted_at ?? "", + deleted_at: d?.deleted_at ?? null, created_by: d?.created_by ?? "test_runner", created_at: d?.created_at ?? new Date(), updated_by: d?.updated_by ?? "updater", @@ -112,8 +112,16 @@ export const makeTestAccount = async ( account_id: accountId, role: d?.role ?? "admin none", author_id: d?.author_id ?? undefined, - accepted_eula_version: d?.accepted_eula_version ?? "1.0", - accepted_dpa_version: d?.accepted_dpa_version ?? "1.0", + accepted_eula_version: + d?.accepted_eula_version !== undefined + ? d.accepted_eula_version + : "1.0", + accepted_privacy_notice_version: + d?.accepted_privacy_notice_version !== undefined + ? d.accepted_privacy_notice_version + : "1.0", + accepted_dpa_version: + d?.accepted_dpa_version !== undefined ? d.accepted_dpa_version : "1.0", email_verified: d?.email_verified ?? true, auto_renew: d?.auto_renew ?? true, notification: d?.notification ?? true, diff --git a/dictation_function/src/test/licenseAlert.spec.ts b/dictation_function/src/test/licenseAlert.spec.ts index c3891a0..f013f47 100644 --- a/dictation_function/src/test/licenseAlert.spec.ts +++ b/dictation_function/src/test/licenseAlert.spec.ts @@ -80,7 +80,7 @@ describe("licenseAlert", () => { // redisからキャッシュが削除されていることを確認 const getAsync = promisify(redisClient.keys).bind(redisClient); const keys = await getAsync(`*`); - expect(keys).toHaveLength(0); + expect(keys).toHaveLength(0); }); it("ライセンス在庫不足メール、ライセンス失効警告メールが送信されること", async () => { @@ -224,6 +224,51 @@ describe("licenseAlert", () => { const keys = await getAsync(`*`); expect(keys).toHaveLength(0); }); + + it("規約同意していない管理者ユーザーに対して、ライセンス失効警告メール・在庫不足メールが送信されないこと", async () => { + if (!source) fail(); + const context = new InvocationContext(); + const sendgridMock = new SendGridServiceMock() as SendGridService; + const adb2cMock = new AdB2cServiceMock() as AdB2cService; + + // 呼び出し回数でテスト成否を判定 + const spySend = jest.spyOn(sendgridMock, "sendMail"); + + const currentDate = new DateWithZeroTime(); + const expiringSoonDate = new DateWithDayEndTime(currentDate.getTime()); + const { account, admin } = await makeTestAccount( + source, + { tier: 5 }, + { + external_id: "external_id5", + auto_renew: false, + accepted_dpa_version: null, + accepted_eula_version: null, + accepted_privacy_notice_version: null, + } + ); + await createLicense( + source, + 1, + expiringSoonDate, + account.id, + "NORMAL", + "Allocated", + admin.id, + null, + null, + null + ); + await licenseAlertProcessing( + context, + source, + redisClient, + sendgridMock, + adb2cMock + ); + // メール送信がされていないことを確認 + expect(spySend.mock.calls).toHaveLength(0); + }); }); // テスト用sendgrid @@ -305,6 +350,17 @@ export class AdB2cServiceMock { }, ], }, + { + id: "external_id5", + displayName: "test5", + identities: [ + { + signInType: ADB2C_SIGN_IN_TYPE.EMAILADDRESS, + issuer: "issuer", + issuerAssignedId: "test5@mail.com", + }, + ], + }, ]; return AdB2cMockUsers; }