autonomy notify: enforce notify allowlist from config and add guard test

This commit is contained in:
DBT
2026-02-28 13:01:54 +00:00
parent 19e7e550ca
commit 6705a2b4e8
5 changed files with 41 additions and 3 deletions

View File

@@ -29,6 +29,7 @@ type Options struct {
Workspace string
DefaultNotifyChannel string
DefaultNotifyChatID string
NotifyAllowChats []string
NotifyCooldownSec int
NotifySameReasonCooldownSec int
QuietHours string
@@ -636,6 +637,18 @@ func (e *Engine) shouldNotify(key string, reason string) bool {
if strings.TrimSpace(e.opts.DefaultNotifyChannel) == "" || strings.TrimSpace(e.opts.DefaultNotifyChatID) == "" {
return false
}
if len(e.opts.NotifyAllowChats) > 0 {
allowed := false
for _, c := range e.opts.NotifyAllowChats {
if c == e.opts.DefaultNotifyChatID {
allowed = true
break
}
}
if !allowed {
return false
}
}
now := time.Now()
if inQuietHours(now, e.opts.QuietHours) {
return false