Files
checkcle/server/service-operation/notification/manager.go
T
Tola Leng 933e70a3f6 feat: Implement comprehensive multi-channel notification system with templating and SSL monitoring
- Add robust notification system supporting 7+ communication channels with intelligent message templating, resource monitoring, and SSL certificate alerts. Notification Channels: (Telegram, Discord, Slack, Signal, Email, Google Chat, Webhooks).

- This notification system provides enterprise-grade alerting capabilities with extensive customization options and multi-channel redundancy for critical service monitoring.
2025-08-14 20:50:31 +07:00

67 lines
2.7 KiB
Go

package notification
import (
// "log"
"service-operation/pocketbase"
)
// NotificationManager handles all notification operations
type NotificationManager struct {
pbClient *pocketbase.PocketBaseClient
services map[string]NotificationService
serverManager *ServerNotificationManager
uptimeManager *UptimeNotificationManager
sslManager *SSLNotificationManager
}
// NewNotificationManager creates a new notification manager
func NewNotificationManager(pbClient *pocketbase.PocketBaseClient) *NotificationManager {
// Initialize notification services
services := make(map[string]NotificationService)
// log.Printf("🔧 Initializing notification services...")
services["telegram"] = NewTelegramService()
services["signal"] = NewSignalService()
services["discord"] = NewDiscordService()
services["slack"] = NewSlackService()
services["google_chat"] = NewGoogleChatService()
services["email"] = NewEmailService()
services["webhook"] = NewWebhookService()
// log.Printf("✅ Notification services initialized: %v", getKeys(services))
// Create specialized managers
serverManager := NewServerNotificationManager(pbClient, services)
uptimeManager := NewUptimeNotificationManager(pbClient, services)
sslManager := NewSSLNotificationManager(pbClient, services)
return &NotificationManager{
pbClient: pbClient,
services: services,
serverManager: serverManager,
uptimeManager: uptimeManager,
sslManager: sslManager,
}
}
// SendServiceNotification sends notification for a service based on its configuration
func (nm *NotificationManager) SendServiceNotification(payload *NotificationPayload, notificationID, templateID string) error {
return nm.serverManager.SendServiceNotification(payload, notificationID, templateID)
}
// SendResourceNotification sends notification for specific resource alerts (CPU, RAM, Disk, etc.)
func (nm *NotificationManager) SendResourceNotification(payload *NotificationPayload, notificationID, templateID, resourceType string) error {
return nm.serverManager.SendResourceNotification(payload, notificationID, templateID, resourceType)
}
// SendUptimeServiceNotification sends notification for uptime services using service templates
func (nm *NotificationManager) SendUptimeServiceNotification(payload *NotificationPayload, notificationID, templateID string) error {
return nm.uptimeManager.SendUptimeServiceNotification(payload, notificationID, templateID)
}
// SendSSLNotification sends notification for SSL certificates using SSL templates
func (nm *NotificationManager) SendSSLNotification(payload *NotificationPayload, notificationID, templateID string) error {
return nm.sslManager.SendSSLNotification(payload, notificationID, templateID)
}