== operator seems kinda unreliable for Types.ObjectId
All checks were successful
Build / build (push) Successful in 54s
Build / build (pull_request) Successful in 1m59s

This commit is contained in:
Sainan 2025-05-07 11:10:30 +02:00
parent 8c0ff5d150
commit d1762c3426
4 changed files with 5 additions and 5 deletions

View File

@ -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,

View File

@ -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);

View File

@ -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));
}

View File

@ -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 }),