From c63ef844e84f49643bd19dd8700f1eab0c77c28a Mon Sep 17 00:00:00 2001 From: Dobrunia Date: Fri, 17 Nov 2023 00:38:18 +0300 Subject: [PATCH] findUserByName --- services/user-service.ts | 52 ++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/services/user-service.ts b/services/user-service.ts index af8406b..fbc1c7a 100644 --- a/services/user-service.ts +++ b/services/user-service.ts @@ -27,32 +27,32 @@ import { JwtPayload } from 'jsonwebtoken'; export async function findUserByName(DATA) { DATA.userName = '%' + DATA.userName + '%'; const usersArray = await find(`users`, `username like ?`, DATA.userName); - const privateChatsArray = await returnAllPrivateChats(); - for (const user of usersArray) { - for (const privateChat of privateChatsArray) { - const usersInChat = await returnUsersInChat(privateChat.id); - if (usersInChat[0] && usersInChat[1]) { - if ( - (usersInChat[0].userID == DATA.myId || - usersInChat[1].userID == DATA.myId) && - (usersInChat[0].userID == user.id || usersInChat[1].userID == user.id) - ) { - // if (DATA.myId == user.id) { - // console.log('Это я'); - // user.chatId = null; - // break; - // } else { - // console.log('Есть чат'); - user.chatId = privateChat.id; - break; - // } - } else { - // console.log('Нет чата'); - user.chatId = null; - } - } - } - } + // const privateChatsArray = await returnAllPrivateChats(); + // for (const user of usersArray) { + // for (const privateChat of privateChatsArray) { + // const usersInChat = await returnUsersInChat(privateChat.id); + // if (usersInChat[0] && usersInChat[1]) { + // if ( + // (usersInChat[0].userID == DATA.myId || + // usersInChat[1].userID == DATA.myId) && + // (usersInChat[0].userID == user.id || usersInChat[1].userID == user.id) + // ) { + // // if (DATA.myId == user.id) { + // // console.log('Это я'); + // // user.chatId = null; + // // break; + // // } else { + // // console.log('Есть чат'); + // user.chatId = privateChat.id; + // break; + // // } + // } else { + // // console.log('Нет чата'); + // user.chatId = null; + // } + // } + // } + // } return usersArray; }