diff --git a/agent/main.go b/agent/main.go index 778de73..f9aff8d 100644 --- a/agent/main.go +++ b/agent/main.go @@ -62,7 +62,7 @@ func processPendingTests() { for _, test := range tests { providerType := NotificationType(test.ProviderType) - err := SendNotification(providerType, test.ProviderConfig, test) + err := SendNotification(providerType, test.ProviderConfig, test, "Test Notification from CoreControl") if updateErr := updateTestStatus(test.ID, err == nil); updateErr != nil { log.Printf("Error updating test status: %v", updateErr) @@ -77,10 +77,10 @@ func processPendingTests() { } } -func SendNotification(providerType NotificationType, config json.RawMessage, test NotificationTest) error { +func SendNotification(providerType NotificationType, config json.RawMessage, test NotificationTest, message string) error { switch providerType { case Telegram: - return sendTelegramNotification(config, test) + return sendTelegramNotification(config, test, message) case Ntfy: return sendNtfyNotification(config, test) case SMTP: @@ -90,7 +90,7 @@ func SendNotification(providerType NotificationType, config json.RawMessage, tes } } -func sendTelegramNotification(config json.RawMessage, test NotificationTest) error { +func sendTelegramNotification(config json.RawMessage, test NotificationTest, message string) error { var cfg struct { Token string `json:"token"` ChatID string `json:"chat_id"` @@ -101,7 +101,7 @@ func sendTelegramNotification(config json.RawMessage, test NotificationTest) err } apiUrl := fmt.Sprintf("https://api.telegram.org/bot%s/sendMessage?chat_id=%s&text=%s", - cfg.Token, cfg.ChatID, "Test Notification") + cfg.Token, cfg.ChatID, message) resp, err := http.Get(apiUrl) if err != nil {