From 376ba5e6f042c8a22c2852c2ef16a73c1265c964 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Fri, 22 May 2026 21:01:17 +0000 Subject: [PATCH] Changes Co-authored-by: domfelipe <53182096+domfelipe@users.noreply.github.com> --- src/routeTree.gen.ts | 9 ------ .../configure-telegram-webhook/index.ts | 32 ++++++------------- 2 files changed, 9 insertions(+), 32 deletions(-) diff --git a/src/routeTree.gen.ts b/src/routeTree.gen.ts index 0bb5aca..0fe84b5 100644 --- a/src/routeTree.gen.ts +++ b/src/routeTree.gen.ts @@ -670,12 +670,3 @@ const rootRouteChildren: RootRouteChildren = { export const routeTree = rootRouteImport ._addFileChildren(rootRouteChildren) ._addFileTypes() - -import type { getRouter } from './router.tsx' -import type { createStart } from '@tanstack/react-start' -declare module '@tanstack/react-start' { - interface Register { - ssr: true - router: Awaited> - } -} diff --git a/supabase/functions/configure-telegram-webhook/index.ts b/supabase/functions/configure-telegram-webhook/index.ts index 550807f..8848a8a 100644 --- a/supabase/functions/configure-telegram-webhook/index.ts +++ b/supabase/functions/configure-telegram-webhook/index.ts @@ -1,5 +1,6 @@ // configure-telegram-webhook -// Gera secret aleatório, configura webhook no Telegram e marca telegram_webhook_configured=true. +// Mantém compatibilidade com o wizard: garante que o webhook do Telegram fique desligado, +// pois o Hermes responde via polling/runtime. import { createClient } from "https://esm.sh/@supabase/supabase-js@2.57.4"; import { corsHeaders } from "../_shared/cors.ts"; @@ -12,14 +13,6 @@ function jsonResponse(body: unknown, status = 200): Response { }); } -function randomHex(bytes: number): string { - const buf = new Uint8Array(bytes); - crypto.getRandomValues(buf); - return Array.from(buf) - .map((b) => b.toString(16).padStart(2, "0")) - .join(""); -} - // deno-lint-ignore no-explicit-any async function getDecryptedSecret( admin: any, @@ -81,21 +74,14 @@ Deno.serve(async (req) => { ); } - const webhookSecret = randomHex(32); - const webhookUrl = - `${supabaseUrl}/functions/v1/telegram-webhook?token=${agent.uuid_tenant}`; - - const setRes = await telegramApi(token, "setWebhook", { - url: webhookUrl, - allowed_updates: ["message"], - drop_pending_updates: true, - secret_token: webhookSecret, + const deleteRes = await telegramApi(token, "deleteWebhook", { + drop_pending_updates: false, }); - if (!setRes.ok) { - console.error("setWebhook failed", setRes); + if (!deleteRes.ok) { + console.error("deleteWebhook failed", deleteRes); return jsonResponse( - { error: "Falha ao configurar webhook no Telegram." }, + { error: "Falha ao liberar o Telegram para o runtime do agente." }, 500, ); } @@ -103,8 +89,8 @@ Deno.serve(async (req) => { const { error: updErr } = await admin .from("agent_instances") .update({ - telegram_webhook_secret: webhookSecret, - telegram_webhook_configured: true, + telegram_webhook_secret: null, + telegram_webhook_configured: false, updated_at: new Date().toISOString(), }) .eq("id", agent.id);