diff --git a/src/controllers/api/addFriendController.ts b/src/controllers/api/addFriendController.ts index f246f444..bbb629d9 100644 --- a/src/controllers/api/addFriendController.ts +++ b/src/controllers/api/addFriendController.ts @@ -17,7 +17,7 @@ export const addFriendController: RequestHandler = async (req, res) => { Friendship.find({ friend: accountId }, "owner") ]); for (const externalFriendship of externalFriendships) { - if (!internalFriendships.find(x => x.friend == externalFriendship.owner)) { + if (!internalFriendships.find(x => x.friend.equals(externalFriendship.owner))) { promises.push( Friendship.insertOne({ owner: accountId, diff --git a/src/controllers/api/getFriendsController.ts b/src/controllers/api/getFriendsController.ts index 83d0c8a1..684e9bcc 100644 --- a/src/controllers/api/getFriendsController.ts +++ b/src/controllers/api/getFriendsController.ts @@ -18,7 +18,7 @@ export const getFriendsController: RequestHandler = async (req: Request, res: Re Friendship.find({ friend: accountId }, "owner Note") ]); for (const externalFriendship of externalFriendships) { - if (!internalFriendships.find(x => x.friend == externalFriendship.owner)) { + if (!internalFriendships.find(x => x.friend.equals(externalFriendship.owner))) { response.IncomingFriendRequests.push({ _id: toOid(externalFriendship.owner), Note: externalFriendship.Note @@ -29,7 +29,7 @@ export const getFriendsController: RequestHandler = async (req: Request, res: Re const friendInfo: IFriendInfo = { _id: toOid(internalFriendship.friend) }; - if (externalFriendships.find(x => x.owner == internalFriendship.friend)) { + if (externalFriendships.find(x => x.owner.equals(internalFriendship.friend))) { response.Current.push(friendInfo); } else { response.OutgoingFriendRequests.push(friendInfo); diff --git a/src/controllers/api/removeFriendController.ts b/src/controllers/api/removeFriendController.ts index c2f3d27c..20243753 100644 --- a/src/controllers/api/removeFriendController.ts +++ b/src/controllers/api/removeFriendController.ts @@ -14,7 +14,7 @@ export const removeFriendGetController: RequestHandler = async (req, res) => { const promises: Promise[] = []; const friends: IOid[] = []; for (const externalFriendship of externalFriendships) { - if (!internalFriendships.find(x => x.friend == externalFriendship.owner)) { + if (!internalFriendships.find(x => x.friend.equals(externalFriendship.owner))) { promises.push(Friendship.deleteOne({ _id: externalFriendship._id }) as unknown as Promise); friends.push(toOid(externalFriendship.owner)); } diff --git a/src/services/friendService.ts b/src/services/friendService.ts index a1e1b67c..a17c9750 100644 --- a/src/services/friendService.ts +++ b/src/services/friendService.ts @@ -29,7 +29,7 @@ export const areFriendsOfFriends = async (a: Types.ObjectId | string, b: Types.O Friendship.find({ owner: b }) ]); for (const aInternalFriend of aInternalFriends) { - if (bInternalFriends.find(x => x.friend == aInternalFriend.friend)) { + if (bInternalFriends.find(x => x.friend.equals(aInternalFriend.friend))) { const c = aInternalFriend.friend; const [cAcceptedA, cAcceptedB] = await Promise.all([ Friendship.exists({ owner: c, friend: a }),