Skip to content

Commit

Permalink
refactor: timelines/:id 응답 시 isOwner 필드 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
kmi0817 committed Dec 11, 2023
1 parent d688c9f commit 2c2cce9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions BE/src/timelines/timelines.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,15 @@ export class TimelinesController {
description: 'id에 해당하는 타임라인을 반환합니다.',
})
@ApiOkResponse({ schema: { example: findOne_OK } })
async findOne(@Param('id', ParseUUIDPipe) id: string): Promise<Timeline> {
return this.timelinesService.findOneWithURL(id);
async findOne(@Req() request, @Param('id', ParseUUIDPipe) id: string) {
const timeline = await this.timelinesService.findOneWithURL(id);
delete timeline.posting.writer.resourceId;
delete timeline.posting.writer.socialType;
delete timeline.posting.writer.allowedIp;
delete timeline.posting.writer.bannedIp;

const userId = request['user'].id;
return { ...timeline, isOwner: timeline.posting.writer.id === userId };
}

@Put(':id')
Expand Down

0 comments on commit 2c2cce9

Please sign in to comment.