Update profile.js
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
|
||||||
|
// Функция для запроса профиля Anixart
|
||||||
async function getProfileFromAnixart(profileId, token = '') {
|
async function getProfileFromAnixart(profileId, token = '') {
|
||||||
const url = `https://api.anixart.tv/profile/${profileId}${token ? `?token=${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 response = await axios.get(url);
|
||||||
const profileData = response.data;
|
const profileData = response.data;
|
||||||
|
|
||||||
// Изначально предполагаем, что не верифицирован
|
|
||||||
let isVerified = false;
|
let isVerified = false;
|
||||||
|
|
||||||
|
// Проверка верификации
|
||||||
try {
|
try {
|
||||||
const verifiedResponse = await axios.get('https://anixart.seele.su/api/is_verified');
|
const verifiedResponse = await axios.get('https://anixart.seele.su/api/is_verified');
|
||||||
const verifiedList = verifiedResponse.data;
|
const verifiedList = verifiedResponse.data;
|
||||||
|
|
||||||
if (Array.isArray(verifiedList) && verifiedList.includes(profileId.toString())) {
|
if (Array.isArray(verifiedList) && verifiedList.includes(profileId.toString())) {
|
||||||
isVerified = true;
|
isVerified = true;
|
||||||
profileData.profile.is_verified = true; // Обновляем в профиле
|
profileData.profile.is_verified = true;
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
// Не удалось проверить верификацию — игнорируем
|
// Ошибку верификации игнорируем
|
||||||
}
|
}
|
||||||
|
|
||||||
// Тестовая вставка (можно отключить закомментировав строку ниже)
|
// Подгружаем кастомные роли по URL
|
||||||
// profileData.profile.privilege_level = 3;
|
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 {
|
return {
|
||||||
...profileData,
|
...profileData,
|
||||||
|
|||||||
Reference in New Issue
Block a user