Files
checkcle/server/service-operation/notification/manager.go
T
MrSchneemann 91ceddc489 feat: add Matrix chat notification support (#211)
Implements native Matrix notification channel support, allowing users
to receive service alerts in any Matrix room via the Client-Server API.

Changes:
- server/service-operation/notification/matrix.go: new Matrix service
  implementing the NotificationService interface (PUT /_matrix/client/v3/...)
- server/service-operation/notification/types.go: add MatrixHomeserver,
  MatrixRoomID, MatrixAccessToken fields to AlertConfiguration
- server/service-operation/notification/manager.go: register MatrixService
- server/pb_migrations/1772200000_updated_alert_configurations_matrix.js:
  PocketBase migration adding matrix fields and notification_type value
- application: Matrix option in channel dialog with homeserver/room/token
  fields, tab filter, list display, type definitions and translations (en, km)
- application/public/upload/notification/matrix.png: Matrix channel icon
2026-03-01 10:48:01 +01:00

72 lines
2.9 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()
services["ntfy"] = NewNtfyService()
services["pushover"] = NewPushoverService()
services["notifiarr"] = NewNotifiarrService()
services["gotify"] = NewGotifyService()
services["matrix"] = NewMatrixService()
// 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)
}