From 2e32af0b6743c1b3a63f75d26a7038a59cce53de Mon Sep 17 00:00:00 2001 From: niamu01 Date: Thu, 14 Dec 2023 23:34:46 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20:recycle:=20=EB=A6=AC=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=EC=97=90=20=EC=9E=90=EC=8B=A0=EC=9D=B4=20=EC=9E=88?= =?UTF-8?q?=EB=8A=94=20=EA=B2=BD=EC=9A=B0=20isFollowing=EC=9D=84=20null?= =?UTF-8?q?=EB=A1=9C=20=EB=B0=98=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - #405 --- app/src/follow/follow.service.ts | 16 +++++++++++----- app/src/follow/model/follow.model.ts | 4 ++-- app/src/schema.gql | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/app/src/follow/follow.service.ts b/app/src/follow/follow.service.ts index 098c0491..1a63c220 100644 --- a/app/src/follow/follow.service.ts +++ b/app/src/follow/follow.service.ts @@ -226,12 +226,18 @@ export class FollowService { throw new NotFoundException(); } - const isFollowed = await this.followModel.findOne({ - userId: userId, - followId: user.id, - }); + let isFollowing: boolean | undefined = undefined; + + if (userId !== user.id) { + const isFollowed = await this.followModel.findOne({ + userId: userId, + followId: user.id, + }); + + isFollowing = !!isFollowed; + } - return { isFollowing: !!isFollowed, user }; + return { isFollowing, user }; }); return Promise.all(followList); diff --git a/app/src/follow/model/follow.model.ts b/app/src/follow/model/follow.model.ts index 928f7bc4..8eb28961 100644 --- a/app/src/follow/model/follow.model.ts +++ b/app/src/follow/model/follow.model.ts @@ -3,8 +3,8 @@ import { UserPreview } from 'src/common/models/common.user.model'; @ObjectType() export class FollowList { - @Field() - isFollowing: boolean; + @Field({ nullable: true }) + isFollowing?: boolean; @Field() user: UserPreview; diff --git a/app/src/schema.gql b/app/src/schema.gql index 41945f97..a8938161 100644 --- a/app/src/schema.gql +++ b/app/src/schema.gql @@ -60,7 +60,7 @@ type UserRankingIndexPaginated { } type FollowList { - isFollowing: Boolean! + isFollowing: Boolean user: UserPreview! }