发布 0.3.0:恢复 Chat 接口并增强云端事件通知
CI / test (push) Successful in 31s
Release / release (push) Successful in 48s

This commit is contained in:
2026-07-13 10:13:44 +08:00
parent 489cb49cb3
commit c7cc5616ed
31 changed files with 1682 additions and 1625 deletions
+23 -1
View File
@@ -322,12 +322,34 @@ func relayEventShortName(eventType string) string {
}
// criticalEventVars 判定关键事件并生成模板变量;非关键事件 ok 为 false。
// actor/ip/outcome/resource 缺失时兜底 —,detail 包装为独立行(空则不占行)。
func criticalEventVars(alias string, p parsedEvent) (map[string]string, bool) {
name := relayEventShortName(p.EventType)
if name == "" || !relayCriticalSet[name] {
return nil, false
}
return map[string]string{"tenant": alias, "event": name, "resource": p.ResourceName}, true
return map[string]string{
"tenant": alias, "event": name,
"resource": orDash(p.ResourceName), "actor": orDash(p.Actor),
"ip": orDash(p.SourceIP), "outcome": orDash(p.Outcome),
"detail": detailLine(p.Detail),
}, true
}
// orDash 空值兜底为 —,避免模板出现悬空标签。
func orDash(v string) string {
if v == "" {
return "—"
}
return v
}
// detailLine 把补充说明包装为独立行;为空时不产生多余空行。
func detailLine(v string) string {
if v == "" {
return ""
}
return "\n" + v
}
// notifyCritical 对关键事件推送告警;依赖未注入或对应子类开关关闭时跳过。