Tg with Notifications, bags fixxed

This commit is contained in:
2025-09-04 13:39:53 +03:00
parent f77d19975e
commit 51995c3695
13 changed files with 1775 additions and 34 deletions

View File

@@ -0,0 +1,201 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Тест улучшений Telegram</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 800px;
margin: 0 auto;
padding: 20px;
background-color: #f5f5f5;
}
.container {
background: white;
padding: 20px;
border-radius: 10px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
margin-bottom: 20px;
}
.form-group {
margin-bottom: 15px;
}
label {
display: block;
margin-bottom: 5px;
font-weight: bold;
}
input[type="text"], input[type="number"] {
width: 100%;
padding: 8px;
border: 1px solid #ddd;
border-radius: 4px;
box-sizing: border-box;
}
button {
background: #0084ff;
color: white;
padding: 10px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
margin-right: 10px;
}
button:hover {
background: #0073e6;
}
.result {
background: #f8f9fa;
padding: 15px;
border-radius: 4px;
margin-top: 15px;
white-space: pre-wrap;
font-family: monospace;
}
.error {
background: #f8d7da;
color: #721c24;
border: 1px solid #f5c6cb;
}
.success {
background: #d4edda;
color: #155724;
border: 1px solid #c3e6cb;
}
</style>
</head>
<body>
<h1>Тест улучшений Telegram</h1>
<div class="container">
<h2>1. Получение статуса пользователей</h2>
<div class="form-group">
<label for="token1">JWT Token:</label>
<input type="text" id="token1" placeholder="Введите JWT токен">
</div>
<button onclick="testUsersStatus()">Получить статус пользователей</button>
<div id="result1" class="result" style="display: none;"></div>
</div>
<div class="container">
<h2>2. Получение информации о пользователе по ID</h2>
<div class="form-group">
<label for="token2">JWT Token:</label>
<input type="text" id="token2" placeholder="Введите JWT токен">
</div>
<div class="form-group">
<label for="userId">ID пользователя:</label>
<input type="number" id="userId" placeholder="Введите ID пользователя">
</div>
<button onclick="testUserInfo()">Получить информацию о пользователе</button>
<div id="result2" class="result" style="display: none;"></div>
</div>
<div class="container">
<h2>3. Получение количества непрочитанных сообщений</h2>
<div class="form-group">
<label for="token3">JWT Token:</label>
<input type="text" id="token3" placeholder="Введите JWT токен">
</div>
<div class="form-group">
<label for="contactId">ID контакта:</label>
<input type="number" id="contactId" placeholder="Введите ID контакта">
</div>
<button onclick="testUnreadCount()">Получить количество непрочитанных сообщений</button>
<div id="result3" class="result" style="display: none;"></div>
</div>
<script>
function showResult(elementId, data, isError = false) {
const element = document.getElementById(elementId);
element.style.display = 'block';
element.className = `result ${isError ? 'error' : 'success'}`;
element.textContent = JSON.stringify(data, null, 2);
}
async function testUsersStatus() {
const token = document.getElementById('token1').value;
if (!token) {
showResult('result1', { error: 'Введите JWT токен' }, true);
return;
}
try {
const response = await fetch('/api/users/status', {
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
}
});
const data = await response.json();
if (response.ok) {
showResult('result1', data);
} else {
showResult('result1', data, true);
}
} catch (error) {
showResult('result1', { error: error.message }, true);
}
}
async function testUserInfo() {
const token = document.getElementById('token2').value;
const userId = document.getElementById('userId').value;
if (!token || !userId) {
showResult('result2', { error: 'Введите JWT токен и ID пользователя' }, true);
return;
}
try {
const response = await fetch(`/api/users/${userId}`, {
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
}
});
const data = await response.json();
if (response.ok) {
showResult('result2', data);
} else {
showResult('result2', data, true);
}
} catch (error) {
showResult('result2', { error: error.message }, true);
}
}
async function testUnreadCount() {
const token = document.getElementById('token3').value;
const contactId = document.getElementById('contactId').value;
if (!token || !contactId) {
showResult('result3', { error: 'Введите JWT токен и ID контакта' }, true);
return;
}
try {
const response = await fetch(`/api/messages-read/${contactId}`, {
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
}
});
const data = await response.json();
if (response.ok) {
showResult('result3', data);
} else {
showResult('result3', data, true);
}
} catch (error) {
showResult('result3', { error: error.message }, true);
}
}
</script>
</body>
</html>