diff --git a/dictation_server/src/api/odms/openapi.json b/dictation_server/src/api/odms/openapi.json index 31aaed9..0dd1122 100644 --- a/dictation_server/src/api/odms/openapi.json +++ b/dictation_server/src/api/odms/openapi.json @@ -1967,9 +1967,9 @@ "GetOrderHistoriesRequest": { "type": "object", "properties": { - "limit": { "type": "number" }, - "offset": { "type": "number" }, - "accountId": { "type": "number" } + "limit": { "type": "number", "description": "取得件数" }, + "offset": { "type": "number", "description": "開始位置" }, + "accountId": { "type": "number", "description": "アカウントID" } }, "required": ["limit", "offset", "accountId"] }, @@ -1990,7 +1990,15 @@ "emailVerified": { "type": "boolean" }, "autoRenew": { "type": "boolean" }, "licenseAlert": { "type": "boolean" }, - "notification": { "type": "boolean" } + "notification": { "type": "boolean" }, + "encryption": { "type": "boolean" }, + "prompt": { "type": "boolean" }, + "expiration": { "type": "string", "nullable": true }, + "remaining": { "type": "number", "nullable": true }, + "licenseStatus": { + "type": "string", + "description": "Normal/NoLicense/Alert/Renew" + } }, "required": [ "name", @@ -2001,7 +2009,12 @@ "emailVerified", "autoRenew", "licenseAlert", - "notification" + "notification", + "encryption", + "prompt", + "expiration", + "remaining", + "licenseStatus" ] }, "GetUsersResponse": { diff --git a/dictation_server/src/constants/index.ts b/dictation_server/src/constants/index.ts index 276a4d6..f41cc4d 100644 --- a/dictation_server/src/constants/index.ts +++ b/dictation_server/src/constants/index.ts @@ -182,3 +182,13 @@ export const PNS = { APNS: 'apns', FCM: 'fcm', }; + +/** + * ユーザーのライセンス状態 + */ +export const USER_LICENSE_STATUS = { + NORMAL: 'Normal', + NO_LICENSE: 'NoLicense', + ALERT: 'Alert', + RENEW: 'Renew', +}; diff --git a/dictation_server/src/features/notification/notification.controller.ts b/dictation_server/src/features/notification/notification.controller.ts index 136c75d..2ab80b2 100644 --- a/dictation_server/src/features/notification/notification.controller.ts +++ b/dictation_server/src/features/notification/notification.controller.ts @@ -23,7 +23,6 @@ import jwt from 'jsonwebtoken'; @ApiTags('notification') @Controller('notification') -@ApiBearerAuth() export class NotificationController { constructor(private readonly notificationService: NotificationService) {} @Post('register') diff --git a/dictation_server/src/features/notification/notification.service.spec.ts b/dictation_server/src/features/notification/notification.service.spec.ts index d389da0..bbcb289 100644 --- a/dictation_server/src/features/notification/notification.service.spec.ts +++ b/dictation_server/src/features/notification/notification.service.spec.ts @@ -23,35 +23,40 @@ describe('NotificationService.register', () => { it('DBからのユーザー取得に失敗した場合、エラーとなる', async () => { const notificationHubMockValue = makeDefaultNotificationHubMockValue(); const usersRepositoryMockValue = makeDefaultUsersRepositoryMockValue(); - usersRepositoryMockValue.findUserByExternalId= new Error("DB failed.") + usersRepositoryMockValue.findUserByExternalId = new Error('DB failed.'); const service = await makeNotificationServiceMock( usersRepositoryMockValue, notificationHubMockValue, ); - await expect(service.register('external_id', 'apns', 'handler')).rejects.toEqual( - new HttpException(makeErrorResponse("E009999"), HttpStatus.INTERNAL_SERVER_ERROR) + await expect( + service.register('external_id', 'apns', 'handler'), + ).rejects.toEqual( + new HttpException( + makeErrorResponse('E009999'), + HttpStatus.INTERNAL_SERVER_ERROR, + ), ); }); - it('NotificationHubへの登録に失敗した場合、エラーとなる', async () => { - const notificationHubMockValue = makeDefaultNotificationHubMockValue(); - const usersRepositoryMockValue = makeDefaultUsersRepositoryMockValue(); - notificationHubMockValue.register = new Error("register failed."); + it('NotificationHubへの登録に失敗した場合、エラーとなる', async () => { + const notificationHubMockValue = makeDefaultNotificationHubMockValue(); + const usersRepositoryMockValue = makeDefaultUsersRepositoryMockValue(); + notificationHubMockValue.register = new Error('register failed.'); - const service = await makeNotificationServiceMock( - usersRepositoryMockValue, - notificationHubMockValue, - ); + const service = await makeNotificationServiceMock( + usersRepositoryMockValue, + notificationHubMockValue, + ); - await expect( - service.register('external_id', 'apns', 'handler'), - ).rejects.toEqual( - new HttpException( - makeErrorResponse('E009999'), - HttpStatus.INTERNAL_SERVER_ERROR, - ), - ); - }); + await expect( + service.register('external_id', 'apns', 'handler'), + ).rejects.toEqual( + new HttpException( + makeErrorResponse('E009999'), + HttpStatus.INTERNAL_SERVER_ERROR, + ), + ); + }); }); diff --git a/dictation_server/src/features/users/types/types.ts b/dictation_server/src/features/users/types/types.ts index c164bf8..515336d 100644 --- a/dictation_server/src/features/users/types/types.ts +++ b/dictation_server/src/features/users/types/types.ts @@ -1,6 +1,9 @@ import { ApiProperty } from '@nestjs/swagger'; import { IsIn } from 'class-validator'; -import { TASK_LIST_SORTABLE_ATTRIBUTES } from '../../../constants'; +import { + TASK_LIST_SORTABLE_ATTRIBUTES, + USER_LICENSE_STATUS, +} from '../../../constants'; import { USER_ROLES } from '../../../constants'; export class ConfirmRequest { @@ -37,6 +40,26 @@ export class User { @ApiProperty() notification: boolean; + + @ApiProperty() + encryption: boolean; + + @ApiProperty() + prompt: boolean; + + @ApiProperty({ nullable: true }) + expiration?: string | undefined; + + @ApiProperty({ nullable: true }) + remaining?: number | undefined; + + @ApiProperty({ + description: `${Object.values(USER_LICENSE_STATUS).join('/')}`, + }) + @IsIn(Object.values(USER_LICENSE_STATUS), { + message: 'invalid license status', + }) + licenseStatus: string; } export class GetUsersResponse { diff --git a/dictation_server/src/features/users/users.service.spec.ts b/dictation_server/src/features/users/users.service.spec.ts index 17343f4..9781663 100644 --- a/dictation_server/src/features/users/users.service.spec.ts +++ b/dictation_server/src/features/users/users.service.spec.ts @@ -586,6 +586,9 @@ const expectedUsers = [ autoRenew: false, licenseAlert: false, notification: false, + encryption: false, + prompt: false, + licenseStatus: 'NoLicense', }, { name: 'Hanako Sato', @@ -597,6 +600,9 @@ const expectedUsers = [ autoRenew: false, licenseAlert: false, notification: false, + encryption: false, + prompt: false, + licenseStatus: 'NoLicense', }, ]; diff --git a/dictation_server/src/features/users/users.service.ts b/dictation_server/src/features/users/users.service.ts index d43a7f6..767bb65 100644 --- a/dictation_server/src/features/users/users.service.ts +++ b/dictation_server/src/features/users/users.service.ts @@ -22,6 +22,7 @@ import { User as EntityUser } from '../../repositories/users/entity/user.entity' import { UsersRepositoryService } from '../../repositories/users/users.repository.service'; import { GetRelationsResponse, User } from './types/types'; import { EmailAlreadyVerifiedError } from '../../repositories/users/errors/types'; +import { USER_LICENSE_STATUS } from '../../constants'; @Injectable() export class UsersService { @@ -321,6 +322,10 @@ export class UsersService { user.autoRenew = dbUsers[i].auto_renew; user.licenseAlert = dbUsers[i].license_alert; user.notification = dbUsers[i].notification; + // TODO: 仮の値を入れておく + user.encryption = false; + user.prompt = false; + user.licenseStatus = USER_LICENSE_STATUS.NO_LICENSE; users.push(user); } return users;