From 08e5a9cd4af261aa7eb4deced13e061bc2815007 Mon Sep 17 00:00:00 2001 From: "makabe.t" Date: Wed, 25 Oct 2023 08:47:15 +0000 Subject: [PATCH] =?UTF-8?q?Merged=20PR=20525:=20=E3=83=95=E3=82=A1?= =?UTF-8?q?=E3=82=A4=E3=83=AB=E3=82=A2=E3=83=83=E3=83=97=E3=83=AD=E3=83=BC?= =?UTF-8?q?=E3=83=89=E5=85=88=E5=8F=96=E5=BE=97API=E3=81=AE=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 概要 [Task2935: ファイルアップロード先取得APIの修正](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/2935) - ファイルアップロード先取得APIの実装を修正しました。 - ContorollerからServiceへ外部ユーザーIDを渡す想定の部分がアクセストークンをそのまま渡すようになっていたので引数を修正しました。 - ログを整理して引数がわかるようにしています。 ## レビューポイント - 共有 - ログ内容は適切か ## UIの変更 - なし ## 動作確認状況 - ローカルで確認 --- .../src/features/files/files.controller.ts | 2 +- .../src/features/files/files.service.ts | 30 ++----------------- .../users/users.repository.service.ts | 2 +- 3 files changed, 5 insertions(+), 29 deletions(-) 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; }