From a1895c7617f35f97d28e53511e1f422123868ccd 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 18:55:08 +0500 Subject: [PATCH] Update profile.js --- api/v1/src/profile.js | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/api/v1/src/profile.js b/api/v1/src/profile.js index bdc5cc9..4bcbb66 100644 --- a/api/v1/src/profile.js +++ b/api/v1/src/profile.js @@ -1,5 +1,6 @@ const axios = require('axios'); +// Функция для запроса профиля Anixart async function getProfileFromAnixart(profileId, token = '') { const url = `https://api.anixart.tv/profile/${profileId}${token ? `?token=${token}` : ''}`; @@ -7,23 +8,36 @@ async function getProfileFromAnixart(profileId, token = '') { const response = await axios.get(url); const profileData = response.data; - // Изначально предполагаем, что не верифицирован let isVerified = false; + // Проверка верификации try { const verifiedResponse = await axios.get('https://anixart.seele.su/api/is_verified'); const verifiedList = verifiedResponse.data; if (Array.isArray(verifiedList) && verifiedList.includes(profileId.toString())) { isVerified = true; - profileData.profile.is_verified = true; // Обновляем в профиле + profileData.profile.is_verified = true; } } catch { - // Не удалось проверить верификацию — игнорируем + // Ошибку верификации игнорируем } - // Тестовая вставка (можно отключить закомментировав строку ниже) - // profileData.profile.privilege_level = 3; + // Подгружаем кастомные роли по URL + try { + const rolesResponse = await axios.get('https://anixart.seele.su/api/is_roles'); + const rolesList = rolesResponse.data; + + const userRoles = rolesList.find(entry => entry.id === Number(profileId)); + if (userRoles && Array.isArray(userRoles.roles)) { + profileData.profile.roles = userRoles.roles; + } + } catch { + // Ошибку загрузки ролей игнорируем + } + + // // Тестовое поле privilege_level (можно отключить) + // profileData.profile.privilege_level = 0; return { ...profileData,