fix: improve IM user account search

This commit is contained in:
richjohnrambo
2026-08-19 17:23:36 +08:00
parent b3d18f9d8d
commit 73ddb2d9fa
4 changed files with 87 additions and 4 deletions
+3 -2
View File
@@ -4077,7 +4077,7 @@ func TestServeIMUserSearch(t *testing.T) {
oldRelations := store.Relations
peer := types.Uid(2)
store.Relations = &testRelationsStore{searchResults: []types.UserSearchItem{{
User: &types.User{ObjHeader: types.ObjHeader{Id: peer.String()}, TenantID: 7, Public: map[string]any{"display_name": "Alice", "avatar_file_id": "file-1"}},
User: &types.User{ObjHeader: types.ObjHeader{Id: peer.String()}, TenantID: 7, Public: map[string]any{"display_name": "Alice", "avatar_file_id": "file-1", "public_account": "alice001"}},
Relationship: types.RelationshipNone,
CanAdd: true,
Action: "add",
@@ -4095,7 +4095,8 @@ func TestServeIMUserSearch(t *testing.T) {
}
data := decodeIMHTTPResponse(t, rec).Data.(map[string]any)
items := data["items"].([]any)
if len(items) != 1 || items[0].(map[string]any)["relationship"] != types.RelationshipNone || items[0].(map[string]any)["can_add"] != true {
if len(items) != 1 || items[0].(map[string]any)["relationship"] != types.RelationshipNone || items[0].(map[string]any)["can_add"] != true ||
items[0].(map[string]any)["public_account"] != "alice001" {
t.Fatalf("unexpected search response: %#v", data)
}
}