From 859e5778b88c32caf1d11fb3d539c550c01c817e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=BC=E3=83=BC=E3=83=AC?= Date: Sat, 3 May 2025 20:40:33 +0500 Subject: [PATCH] Create profile-search.js --- api/v1/src/profile-search.js | 41 ++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 api/v1/src/profile-search.js diff --git a/api/v1/src/profile-search.js b/api/v1/src/profile-search.js new file mode 100644 index 0000000..e5debda --- /dev/null +++ b/api/v1/src/profile-search.js @@ -0,0 +1,41 @@ +const axios = require('axios'); + +// Функция получения кастомного списка верифицированных пользователей +const getVerifiedUsers = require('./is_verified'); + +async function searchProfiles(page = 1, query = '', searchBy = 0, token = '') { + const url = `https://api.anixart.tv/search/profiles/${page}${token ? `?token=${token}` : ''}`; + const verifiedList = getVerifiedUsers(); + + try { + const response = await axios.post(url, { + query, + searchBy, + }); + + const searchResult = response.data; + + if (Array.isArray(searchResult.content)) { + searchResult.content = searchResult.content.map((profile) => { + const isVerified = verifiedList.includes(profile.id.toString()); + return { + ...profile, + is_verified: isVerified || profile.is_verified, + }; + }); + } + + return searchResult; + } catch (error) { + return { + code: 2, + content: [], + total_count: 0, + total_page_count: 0, + current_page: page, + error: error.message, + }; + } +} + +module.exports = { searchProfiles };