diff --git a/dictation_server/src/features/files/files.controller.ts b/dictation_server/src/features/files/files.controller.ts index 4a72268..8578e52 100644 --- a/dictation_server/src/features/files/files.controller.ts +++ b/dictation_server/src/features/files/files.controller.ts @@ -182,7 +182,7 @@ export class FilesController { const context = makeContext(userId); - const url = await this.filesService.publishUploadSas(context, accessToken); + const url = await this.filesService.publishUploadSas(context, userId); return { url }; } diff --git a/dictation_server/src/features/files/files.service.ts b/dictation_server/src/features/files/files.service.ts index db97e77..96ac698 100644 --- a/dictation_server/src/features/files/files.service.ts +++ b/dictation_server/src/features/files/files.service.ts @@ -210,49 +210,25 @@ export class FilesService { externalId: string, ): Promise { this.logger.log( - `[IN] [${context.trackingId}] ${this.publishUploadSas.name}`, + `[IN] [${context.trackingId}] ${this.publishUploadSas.name} | params: { externalId: ${externalId} };`, ); //DBから国情報とアカウントIDを取得する - let accountId: number; - let country: string; try { const user = await this.usersRepository.findUserByExternalId(externalId); if (!user.account) { throw new AccountNotFoundError('account not found.'); } - accountId = user.account_id; - country = user.account.country; - } catch (e) { - this.logger.error(`error=${e}`); - this.logger.log( - `[OUT] [${context.trackingId}] ${this.publishUploadSas.name}`, - ); - throw new HttpException( - makeErrorResponse('E009999'), - HttpStatus.INTERNAL_SERVER_ERROR, - ); - } + const accountId = user.account_id; + const country = user.account.country; - try { // 国に応じたリージョンのBlobストレージにコンテナが存在するか確認 await this.blobStorageService.containerExists( context, accountId, country, ); - } catch (e) { - this.logger.error(`error=${e}`); - this.logger.log( - `[OUT] [${context.trackingId}] ${this.publishUploadSas.name}`, - ); - throw new HttpException( - makeErrorResponse('E009999'), - HttpStatus.INTERNAL_SERVER_ERROR, - ); - } - try { // SASトークン発行 const url = await this.blobStorageService.publishUploadSas( context, diff --git a/dictation_server/src/repositories/users/users.repository.service.ts b/dictation_server/src/repositories/users/users.repository.service.ts index 0a9dcab..f579c3e 100644 --- a/dictation_server/src/repositories/users/users.repository.service.ts +++ b/dictation_server/src/repositories/users/users.repository.service.ts @@ -116,7 +116,7 @@ export class UsersRepositoryService { }); if (!user) { - throw new UserNotFoundError(); + throw new UserNotFoundError(`User not found. externalId: ${sub}`); } return user; }