fix: make ai task events realtime only

This commit is contained in:
richjohnrambo
2026-09-30 11:37:49 +08:00
parent d75c6fa0b4
commit dcb131dcea
2 changed files with 56 additions and 1 deletions
+45
View File
@@ -0,0 +1,45 @@
package main
import (
"testing"
"github.com/tinode/chat/server/store"
)
func TestExecuteKafkaWorkbenchAITaskEventSkipsNotification(t *testing.T) {
oldSecurity := store.Security
security := &testUserSecurityStore{}
store.Security = security
t.Cleanup(func() {
store.Security = oldSecurity
})
event := kafkaWorkbenchEvent{
EventID: "wbe_ai_1",
TenantID: 7,
ActorUserID: 1,
Module: "ai",
Action: "workbench.ai.task.updated",
ResourceID: "aitask_1",
TargetUserIDs: []int64{2},
Title: "AI 任务完成",
Summary: "表格分析已完成",
Data: map[string]any{
"task_id": "aitask_1",
"feature": "smart_table",
"status": "succeeded",
"result_type": "record",
"record_id": "airec_1",
},
}
if event.shouldCreateNotification() {
t.Fatal("ai task event must be realtime-only")
}
err := executeKafkaWorkbenchEvent(event)
if err != nil {
t.Fatalf("executeKafkaWorkbenchEvent returned error: %v", err)
}
if len(security.notifications) != 0 {
t.Fatalf("ai task event should not create offline notification: %#v", security.notifications)
}
}