Spaces:
Running

axeronis commited on
Commit
eaae5c4
·
1 Parent(s): be18586

Fix: Smart handling of TELEGRAM_WEBHOOK_URL to prevent double /api/v1

Browse files
Files changed (1) hide show
  1. backend/app/api/channels.py +4 -1
backend/app/api/channels.py CHANGED
@@ -66,7 +66,10 @@ async def connect_telegram_bot(
66
  detail="Неверный формат токена. Токен должен быть вида: 123456:ABC-DEF..."
67
  )
68
 
69
- webhook_base = settings.TELEGRAM_WEBHOOK_URL or "https://your-domain.com"
 
 
 
70
  webhook_url = f"{webhook_base}/api/v1/webhook/telegram/{tenant_id}"
71
 
72
  telegram_api_url = f"https://api.telegram.org/bot{bot_token}/setWebhook"
 
66
  detail="Неверный формат токена. Токен должен быть вида: 123456:ABC-DEF..."
67
  )
68
 
69
+ webhook_base = (settings.TELEGRAM_WEBHOOK_URL or "https://your-domain.com").rstrip("/")
70
+ if webhook_base.endswith("/api/v1"):
71
+ webhook_base = webhook_base[:-7]
72
+
73
  webhook_url = f"{webhook_base}/api/v1/webhook/telegram/{tenant_id}"
74
 
75
  telegram_api_url = f"https://api.telegram.org/bot{bot_token}/setWebhook"