Merged PR 525: ファイルアップロード先取得APIの修正

## 概要
[Task2935: ファイルアップロード先取得APIの修正](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/2935)

- ファイルアップロード先取得APIの実装を修正しました。
  - ContorollerからServiceへ外部ユーザーIDを渡す想定の部分がアクセストークンをそのまま渡すようになっていたので引数を修正しました。
- ログを整理して引数がわかるようにしています。

## レビューポイント
- 共有
- ログ内容は適切か

## UIの変更
- なし

## 動作確認状況
- ローカルで確認
This commit is contained in:
makabe.t 2023-10-25 08:47:15 +00:00
parent c283df9b0a
commit 08e5a9cd4a
3 changed files with 5 additions and 29 deletions

View File

@ -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 };
}

View File

@ -210,49 +210,25 @@ export class FilesService {
externalId: string,
): Promise<string> {
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,

View File

@ -116,7 +116,7 @@ export class UsersRepositoryService {
});
if (!user) {
throw new UserNotFoundError();
throw new UserNotFoundError(`User not found. externalId: ${sub}`);
}
return user;
}