From d5ea48719000fcc96a6fdb8705b979ea0d4f2347 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Mon, 27 Apr 2026 15:45:21 +0000 Subject: [PATCH] Changes Co-authored-by: domfelipe <53182096+domfelipe@users.noreply.github.com> --- supabase/functions/capture-telegram-owner/index.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/supabase/functions/capture-telegram-owner/index.ts b/supabase/functions/capture-telegram-owner/index.ts index 02d14fa..07d531e 100644 --- a/supabase/functions/capture-telegram-owner/index.ts +++ b/supabase/functions/capture-telegram-owner/index.ts @@ -5,6 +5,8 @@ // 1) grava telegram_user_chat_id em agent_instances // 2) envia mensagem de confirmação ao usuário // 3) limpa o offset (markAsRead) chamando getUpdates com offset alto +// 4) se o agente já está provisionado no Railway, atualiza as env vars +// TELEGRAM_ALLOWED_USERS / TELEGRAM_HOME_CHANNEL e dispara redeploy // // É chamada repetidamente pelo frontend (poll a cada 2s) até retornar // { found: true } ou o usuário desistir. @@ -12,6 +14,13 @@ import { createClient } from "https://esm.sh/@supabase/supabase-js@2.57.4"; import { corsHeaders } from "../_shared/cors.ts"; import { telegramApi } from "../_shared/telegram.ts"; +import { + deployRailwayService, + getServiceContext, + upsertRailwayVariableCollection, +} from "../_shared/railway.ts"; + +const RAILWAY_API_TOKEN = Deno.env.get("RAILWAY_API_TOKEN"); interface TelegramUpdate { update_id: number;