Skip to content

Commit

Permalink
[BE] Feat : 탈퇴한 회원을 차단후 조회했을 때 null 반환하게 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
koomin1227 committed Dec 13, 2023
1 parent 04eb27a commit b962cc5
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions BE/src/users-block/users-block.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import { Repository } from 'typeorm';
import { UserEntity } from 'src/entities/user.entity';
import { ConfigService } from '@nestjs/config';

interface BlockedUser {
user_id: string;
nickname?: string;
profile_img?: string;
}

@Injectable()
export class UsersBlockService {
constructor(
Expand Down Expand Up @@ -52,15 +58,19 @@ export class UsersBlockService {
});

const blockedUsers = res.reduce((acc, cur) => {
const user = {
nickname: cur.blockedUser.nickname,
profile_img:
const user: BlockedUser = {
user_id: cur.blocked_user,
};
if (cur.blockedUser === null) {
user.nickname = null;
user.profile_img = null;
} else {
user.nickname = cur.blockedUser.nickname;
user.profile_img =
cur.blockedUser.profile_img === null
? this.configService.get('DEFAULT_PROFILE_IMAGE')
: cur.blockedUser.profile_img,
user_id: cur.blockedUser.user_hash,
};

: cur.blockedUser.profile_img;
}
acc.push(user);
return acc;
}, []);
Expand Down

0 comments on commit b962cc5

Please sign in to comment.