Skip to content

Commit

Permalink
Merge pull request #101 from depromeet/dev
Browse files Browse the repository at this point in the history
🔨 fix(alarm): 상대방이 날 차단한 정보 따로 저장
  • Loading branch information
ImNM authored Jun 18, 2022
2 parents 55090f9 + 49e7108 commit 7e04a76
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/apis/alarm/pushAlarm.processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ export class PushAlarmProcessor {

// 차집합

const sendToOnlyBlockedUser = userInfo.blockedUsers.filter(
(x) => !userInfo.iBlockUsers.find((user) => user._id.equals(x._id)),
);
// const sendToOnlyBlockedUser = userInfo.blockedUsers.filter(
// (x) => !userInfo.iBlockUsers.find((user) => user._id.equals(x._id)),
// );

const userFcmInfoList = room.userList
? (room.userList as unknown as UserFcmInfoDto[])
Expand All @@ -110,7 +110,7 @@ export class PushAlarmProcessor {

const TokenArray = roomNameAndUserAlarmInfoArray.userFcmInfoList
.filter((e) => {
const checkIfIBlockUser = sendToOnlyBlockedUser.find((user) =>
const checkIfIBlockUser = userInfo.opBlockedUsers.find((user) =>
user._id.equals(e._id),
)
? false
Expand Down
2 changes: 1 addition & 1 deletion src/apis/users/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export class UserService {
myUserIdDto,
otherUserIdDto,
);
console.log('asdfasdfasdfasdfasdf', returnUser);

// auto 시리얼 라이징
return returnUser.iBlockUsers;
}
Expand Down
5 changes: 4 additions & 1 deletion src/models/user.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ export class User {
@Expose()
iBlockUsers: UserProfileDto[];

// @Transform(({ value }) => value || [], { toClassOnly: true })
@Prop({
type: [{ type: Types.ObjectId, ref: User.name }],
})
opBlockedUsers: Types.ObjectId[];

// only for 내부용
@Exclude()
Expand Down
47 changes: 45 additions & 2 deletions src/repositories/user.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export class UserRepository {
{
$addToSet: {
blockedUsers: myUserIdDto.userId,
opBlockedUsers: myUserIdDto.userId,
},
},
{ new: true },
Expand All @@ -155,14 +156,56 @@ export class UserRepository {
_id: 1,
name: 1,
geometry: 1,

category: 1,
userCount: { $size: '$userList' },
},
})
.lean<User>({ defaults: true });
}

// async oppositeBlockUser(
// myUserIdDto: UserIdDto,
// otherUserIdDto: UserIdDto,
// ): Promise<User> {
// // 상대방은 보여지면 안되는 부분에서 나를 추가
// await this.userModel.findOneAndUpdate(
// { _id: myUserIdDto.userId },
// {
// $addToSet: {
// blockedUsers: myUserIdDto.userId,
// },
// },
// { new: true },
// );
// // 내부분은 보여지면 안되는 부분 , 내 차단목록에 추가
// return await this.userModel
// .findOneAndUpdate(
// { _id: myUserIdDto.userId },
// {
// $addToSet: {
// blockedUsers: otherUserIdDto.userId,
// iBlockUsers: otherUserIdDto.userId,
// },
// },
// { new: true },
// )
// .populate({
// path: 'iBlockUsers',
// select: UserProfileSelect,
// })
// .populate({
// path: 'myRoom',
// select: {
// _id: 1,
// name: 1,
// geometry: 1,
// category: 1,
// userCount: { $size: '$userList' },
// },
// })
// .lean<User>({ defaults: true });
// }

async unBlockUser(
myUserIdDto: UserIdDto,
otherUserIdDto: UserIdDto,
Expand All @@ -172,6 +215,7 @@ export class UserRepository {
{
$pull: {
blockedUsers: myUserIdDto.userId,
opBlockedUsers: myUserIdDto.userId,
},
},
{ new: true },
Expand All @@ -198,7 +242,6 @@ export class UserRepository {
name: 1,
category: 1,
geometry: 1,

userCount: { $size: '$userList' },
},
})
Expand Down

0 comments on commit 7e04a76

Please sign in to comment.