Skip to content

Commit

Permalink
refactor: ♻️ follow시 push하기 때문에 set을 다시 호출하던 부분 삭제, 못 찾는 경우와 삭제 실패가 같…
Browse files Browse the repository at this point in the history
…은 404를 throw하여 find하지 않고 바로 delete하여 로직 줄이기

- #413
  • Loading branch information
niamu01 committed Feb 20, 2024
1 parent 90129d7 commit 81e8fe5
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions app/src/follow/follow.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,6 @@ export class FollowService {

cachedfollowingList.push({ userPreview: target, followAt });

await this.followCacheService.set({
id: userId,
type: 'following',
list: cachedfollowingList,
});

const cachedfollowerList = await this.followCacheService.get(
targetId,
'follower',
Expand All @@ -95,31 +89,13 @@ export class FollowService {

cachedfollowerList.push({ userPreview: user, followAt });

await this.followCacheService.set({
id: targetId,
type: 'follower',
list: cachedfollowerList,
});

return {
userId,
followId: targetId,
};
}

async unfollowUser(userId: number, targetId: number): Promise<FollowSuccess> {
const existingFollow = await this.followModel.findOne(
{
userId,
followId: targetId,
},
{ _id: 1 },
);

if (!existingFollow || userId === targetId) {
throw new NotFoundException();
}

const deletedCount = await this.followModel
.deleteOne({
userId,
Expand Down

0 comments on commit 81e8fe5

Please sign in to comment.