feat(tenant): 隔离客服通知文件与后台任务

This commit is contained in:
yml
2026-11-15 16:23:28 +08:00
parent c7dacfa025
commit e994fd9166
52 changed files with 1670 additions and 254 deletions
@@ -30,3 +30,28 @@ func TestDisconnectUserClosesAllConnections(t *testing.T) {
t.Fatalf("online admin connection count = %d, want 1", got)
}
}
func TestNotifyAllAdminsRespectsTenantAndPlatformScope(t *testing.T) {
hub := NewHub(nil)
tenantA := hub.SubscribeAdmin(1, 101, false)
tenantB := hub.SubscribeAdmin(2, 202, false)
platform := hub.SubscribeAdmin(3, 101, true)
hub.NotifyAllAdmins(&ChatEvent{
Type: "conversation_updated",
ConversationID: 9,
TenantIDs: []uint64{101},
})
if got := <-tenantA; got.ConversationID != 9 {
t.Fatalf("tenant A conversation = %d", got.ConversationID)
}
if got := <-platform; got.ConversationID != 9 {
t.Fatalf("platform conversation = %d", got.ConversationID)
}
select {
case event := <-tenantB:
t.Fatalf("tenant B received cross-tenant event: %+v", event)
default:
}
}