Update profile.js
This commit is contained in:
@@ -1,30 +1,36 @@
|
|||||||
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}` : ''}`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await axios.get(url);
|
const response = await axios.get(url);
|
||||||
const data = response.data;
|
const profileData = response.data;
|
||||||
|
|
||||||
// По умолчанию флаг is_verified — false
|
// Изначально предполагаем, что не верифицирован
|
||||||
data.is_verified = false;
|
let isVerified = false;
|
||||||
|
|
||||||
// Проверка, есть ли ID в списке verified
|
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())) {
|
||||||
data.is_verified = true;
|
isVerified = true;
|
||||||
|
profileData.profile.is_verified = true; // Обновляем внутри профиля
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// Если не получилось проверить, просто игнорируем и оставляем false
|
||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
return {
|
||||||
|
...profileData,
|
||||||
|
is_verified: isVerified, // Добавляем также в корень ответа
|
||||||
|
};
|
||||||
} catch {
|
} catch {
|
||||||
return {
|
return {
|
||||||
code: 2,
|
code: 2,
|
||||||
profile: null,
|
profile: null,
|
||||||
is_my_profile: false
|
is_my_profile: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user