localhost fix

This commit is contained in:
Andrey Kondratev
2025-08-29 17:33:13 +05:00
parent 9e18de85eb
commit 7cf833af6f
8 changed files with 5791 additions and 193 deletions

View File

@@ -254,9 +254,35 @@ class QuixoticApp {
audioUrl: data.audioUrl,
title: title
};
console.log('📤 Sending data to Telegram:', payload);
this.tg.sendData(JSON.stringify(payload));
this.showMessage('✓ MP3 готов! Отправляем в чат...', 'success');
console.log('📤 Sending data to Telegram via sendData:', payload);
try {
this.tg.sendData(JSON.stringify(payload));
console.log('✅ Data sent via Telegram.sendData');
this.showMessage('✓ MP3 готов! Отправляем в чат...', 'success');
// Fallback: also try to send via HTTP request to our server
setTimeout(async () => {
try {
console.log('🔄 Sending fallback notification to server...');
await fetch('/api/telegram-notify', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
userId: this.tg?.initDataUnsafe?.user?.id,
audioUrl: data.audioUrl,
title: title
})
});
} catch (fallbackError) {
console.log('Fallback notification failed (not critical):', fallbackError);
}
}, 2000); // Wait 2 seconds before fallback
} catch (sendError) {
console.error('❌ Failed to send via Telegram.sendData:', sendError);
this.showMessage('❌ Ошибка отправки в Telegram', 'error');
}
} else {
// For testing in browser - download file
const link = document.createElement('a');