feat: notificaciones Telegram en webhook de Coolify
- CoolifyWebhook parsea el payload y envía mensaje formateado a Telegram - Detecta estado (✅ success / ❌ fail / 🚀 deploying / ⏹ stop / 🔄 restart) - Ruta /webhooks/coolify/:config_id identifica de qué instancia viene - Notifica a todos los chats autorizados del agente bot - GetAgentTelegramConfig() en models para obtener el bot activo Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
a8786e2aca
commit
ee9a2f09d6
@@ -1,6 +1,8 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/sujit-baniya/fiber-boilerplate/app"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
@@ -81,3 +83,15 @@ func CreateAgentAuth(chatID int64, nombre string) error {
|
||||
func DeleteAgentAuth(id uint) error {
|
||||
return app.Http.Database.DB.Delete(&TelegramAgentAuth{}, id).Error
|
||||
}
|
||||
|
||||
// GetAgentTelegramConfig retorna el TelegramConfig vinculado al agente bot activo.
|
||||
func GetAgentTelegramConfig() (*TelegramConfig, error) {
|
||||
var ai AiConfig
|
||||
if err := app.Http.Database.DB.Where("es_agente_bot = ? AND is_active = ?", true, true).First(&ai).Error; err != nil {
|
||||
return nil, fmt.Errorf("no hay agente bot configurado")
|
||||
}
|
||||
if ai.TelegramConfigID == nil {
|
||||
return nil, fmt.Errorf("el agente no tiene Telegram configurado")
|
||||
}
|
||||
return GetTelegramConfigByID(*ai.TelegramConfigID)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user