== operator seems kinda unreliable for Types.ObjectId
This commit is contained in:
parent
8c0ff5d150
commit
d1762c3426
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -14,7 +14,7 @@ export const removeFriendGetController: RequestHandler = async (req, res) => {
|
||||
const promises: Promise<void>[] = [];
|
||||
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<void>);
|
||||
friends.push(toOid(externalFriendship.owner));
|
||||
}
|
||||
|
@ -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 }),
|
||||
|
Loading…
x
Reference in New Issue
Block a user