From fb67a308dc0524610109aad47d8f8426b1691b4d Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Fri, 22 May 2026 00:17:00 -0500 Subject: [PATCH] Update telegram.html --- resources/views/telegram.html | 36 +++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/resources/views/telegram.html b/resources/views/telegram.html index 69cfbe6..d7a055b 100644 --- a/resources/views/telegram.html +++ b/resources/views/telegram.html @@ -283,22 +283,34 @@ function telegramApp() { async testConfig(cfg) { this.testLoading[cfg.ID] = true; this.testResult[cfg.ID] = ''; - const res = await fetch(`/app/telegram/${cfg.ID}/test`, { method: 'POST' }); - const d = await res.json(); - this.testOk[cfg.ID] = d.ok; - this.testResult[cfg.ID] = d.ok ? '✅ Mensaje enviado correctamente.' : ('❌ ' + (d.error || 'Error')); - this.testLoading[cfg.ID] = false; + try { + const res = await fetch(`/app/telegram/${cfg.ID}/test`, { method: 'POST' }); + const d = await res.json(); + this.testOk[cfg.ID] = d.ok; + this.testResult[cfg.ID] = d.ok ? '✅ Mensaje enviado correctamente.' : ('❌ ' + (d.error || 'Error')); + } catch (e) { + this.testOk[cfg.ID] = false; + this.testResult[cfg.ID] = '❌ Error de red: ' + e.message; + } finally { + this.testLoading[cfg.ID] = false; + } }, async setWebhook(cfg) { this.webhookLoading[cfg.ID] = true; this.webhookResult[cfg.ID] = ''; - const res = await fetch(`/app/telegram/${cfg.ID}/set-portal-webhook`, { method: 'POST' }); - const d = await res.json(); - this.webhookOk[cfg.ID] = d.ok; - this.webhookResult[cfg.ID] = d.ok - ? '✅ Webhook registrado: ' + (d.webhook_url || '') - : '❌ Error: ' + (d.telegram?.description || d.error || 'Error desconocido'); - this.webhookLoading[cfg.ID] = false; + try { + const res = await fetch(`/app/telegram/${cfg.ID}/set-portal-webhook`, { method: 'POST' }); + const d = await res.json(); + this.webhookOk[cfg.ID] = d.ok; + this.webhookResult[cfg.ID] = d.ok + ? '✅ Webhook registrado: ' + (d.webhook_url || '') + : '❌ Error: ' + (d.telegram?.description || d.error || 'Error desconocido'); + } catch (e) { + this.webhookOk[cfg.ID] = false; + this.webhookResult[cfg.ID] = '❌ Error de red: ' + e.message; + } finally { + this.webhookLoading[cfg.ID] = false; + } }, async sendMessage() {