== 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")
 | 
					            Friendship.find({ friend: accountId }, "owner")
 | 
				
			||||||
        ]);
 | 
					        ]);
 | 
				
			||||||
        for (const externalFriendship of externalFriendships) {
 | 
					        for (const externalFriendship of externalFriendships) {
 | 
				
			||||||
            if (!internalFriendships.find(x => x.friend == externalFriendship.owner)) {
 | 
					            if (!internalFriendships.find(x => x.friend.equals(externalFriendship.owner))) {
 | 
				
			||||||
                promises.push(
 | 
					                promises.push(
 | 
				
			||||||
                    Friendship.insertOne({
 | 
					                    Friendship.insertOne({
 | 
				
			||||||
                        owner: accountId,
 | 
					                        owner: accountId,
 | 
				
			||||||
 | 
				
			|||||||
@ -18,7 +18,7 @@ export const getFriendsController: RequestHandler = async (req: Request, res: Re
 | 
				
			|||||||
        Friendship.find({ friend: accountId }, "owner Note")
 | 
					        Friendship.find({ friend: accountId }, "owner Note")
 | 
				
			||||||
    ]);
 | 
					    ]);
 | 
				
			||||||
    for (const externalFriendship of externalFriendships) {
 | 
					    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({
 | 
					            response.IncomingFriendRequests.push({
 | 
				
			||||||
                _id: toOid(externalFriendship.owner),
 | 
					                _id: toOid(externalFriendship.owner),
 | 
				
			||||||
                Note: externalFriendship.Note
 | 
					                Note: externalFriendship.Note
 | 
				
			||||||
@ -29,7 +29,7 @@ export const getFriendsController: RequestHandler = async (req: Request, res: Re
 | 
				
			|||||||
        const friendInfo: IFriendInfo = {
 | 
					        const friendInfo: IFriendInfo = {
 | 
				
			||||||
            _id: toOid(internalFriendship.friend)
 | 
					            _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);
 | 
					            response.Current.push(friendInfo);
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            response.OutgoingFriendRequests.push(friendInfo);
 | 
					            response.OutgoingFriendRequests.push(friendInfo);
 | 
				
			||||||
 | 
				
			|||||||
@ -14,7 +14,7 @@ export const removeFriendGetController: RequestHandler = async (req, res) => {
 | 
				
			|||||||
        const promises: Promise<void>[] = [];
 | 
					        const promises: Promise<void>[] = [];
 | 
				
			||||||
        const friends: IOid[] = [];
 | 
					        const friends: IOid[] = [];
 | 
				
			||||||
        for (const externalFriendship of externalFriendships) {
 | 
					        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>);
 | 
					                promises.push(Friendship.deleteOne({ _id: externalFriendship._id }) as unknown as Promise<void>);
 | 
				
			||||||
                friends.push(toOid(externalFriendship.owner));
 | 
					                friends.push(toOid(externalFriendship.owner));
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
				
			|||||||
@ -29,7 +29,7 @@ export const areFriendsOfFriends = async (a: Types.ObjectId | string, b: Types.O
 | 
				
			|||||||
        Friendship.find({ owner: b })
 | 
					        Friendship.find({ owner: b })
 | 
				
			||||||
    ]);
 | 
					    ]);
 | 
				
			||||||
    for (const aInternalFriend of aInternalFriends) {
 | 
					    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 c = aInternalFriend.friend;
 | 
				
			||||||
            const [cAcceptedA, cAcceptedB] = await Promise.all([
 | 
					            const [cAcceptedA, cAcceptedB] = await Promise.all([
 | 
				
			||||||
                Friendship.exists({ owner: c, friend: a }),
 | 
					                Friendship.exists({ owner: c, friend: a }),
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user