feat: Telegram fleet alerts, forge sigil scramble, UI polish, agent ops
- Calibrate: per-event Telegram/SMTP toggles, test notification, chat ID help - Notify on agent connect/reconnect, offline/hashrate/rejection, forge complete - Sigil scramble post-forge uniquification and Dispense Reveal ceremony - Full system check, desktop push, BITS/host-binary persistence, Path Tracer - Dashboard/Crucible visual polish, haptics, sacred geometry, mobile nav - README documents alerts, sigil scramble, and pack-usb workflow - USB bundle repacked via pack-usb.bat (AetherForge.exe + synced agent source)
This commit is contained in:
54
server/internal/alerts/notifier.go
Normal file
54
server/internal/alerts/notifier.go
Normal file
@@ -0,0 +1,54 @@
|
||||
package alerts
|
||||
|
||||
import "log"
|
||||
|
||||
// Notifier sends Telegram/email when Calibrate toggles allow it.
|
||||
type Notifier struct {
|
||||
settings func() Settings
|
||||
}
|
||||
|
||||
func NewNotifier(settings func() Settings) *Notifier {
|
||||
return &Notifier{settings: settings}
|
||||
}
|
||||
|
||||
func (n *Notifier) Emit(event string, title, body string) {
|
||||
if n == nil || n.settings == nil {
|
||||
return
|
||||
}
|
||||
s := n.settings()
|
||||
if !n.eventEnabled(s, event) {
|
||||
return
|
||||
}
|
||||
if s.TelegramBotToken == "" && s.TelegramChatID == "" && !s.EmailEnabled {
|
||||
return
|
||||
}
|
||||
log.Printf("[Notify] %s: %s", event, body)
|
||||
NotifyAll(s.NotifyConfig, title, body)
|
||||
}
|
||||
|
||||
func (n *Notifier) eventEnabled(s Settings, event string) bool {
|
||||
switch event {
|
||||
case EventAgentConnect:
|
||||
return s.Events.AgentConnect
|
||||
case EventAgentReconnect:
|
||||
return s.Events.AgentReconnect
|
||||
case EventBuildComplete:
|
||||
return s.Events.BuildComplete
|
||||
case "offline":
|
||||
return s.Events.AgentOffline
|
||||
case "hashrate_drop":
|
||||
return s.Events.HashrateDrop
|
||||
case "rejection_rate":
|
||||
return s.Events.RejectionRate
|
||||
default:
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// GetSettings exposes current settings (alert test handler).
|
||||
func (n *Notifier) GetSettings() Settings {
|
||||
if n == nil || n.settings == nil {
|
||||
return Settings{}
|
||||
}
|
||||
return n.settings()
|
||||
}
|
||||
Reference in New Issue
Block a user