RemoveMock telegram

This commit is contained in:
2026-03-19 17:09:44 +01:00
parent 83e494e171
commit be5ef212e9
5 changed files with 502 additions and 3 deletions
@@ -161,6 +161,35 @@ class NotificationService:
elif channel_type == "telegram":
if not config.get("chat_id"):
return ChannelTestResult(success=False, message="Chat ID Telegram non configurato")
# Invio reale via Bot API
secret = _decrypt(channel.config_enc) if channel.config_enc else {}
bot_token = secret.get("bot_token")
if not bot_token:
return ChannelTestResult(success=False, message="Bot token Telegram non configurato")
try:
from app.notifications.telegram import TelegramError, send_test_message
result = await send_test_message(
bot_token=bot_token,
chat_id=str(config["chat_id"]),
channel_name=channel.name,
)
msg_id = result.get("message_id")
return ChannelTestResult(
success=True,
message=f"Messaggio Telegram inviato con successo (message_id={msg_id}).",
http_status=200,
)
except TelegramError as exc:
return ChannelTestResult(
success=False,
message=f"Errore Telegram: {exc}",
http_status=exc.http_status,
)
except Exception as exc:
return ChannelTestResult(
success=False,
message=f"Errore imprevisto durante il test Telegram: {exc}",
)
elif channel_type == "whatsapp":
if not config.get("phone_number"):
return ChannelTestResult(success=False, message="Numero WhatsApp non configurato")