From 7472c29de0b6bef154803cd88462b048ae03e48b Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Mon, 11 May 2026 13:29:35 -0400 Subject: [PATCH] collab: Route `fuzzy_search_users` through Cloud (#56436) This PR makes it so we route the `UserService::fuzzy_search_users` call through Cloud instead of hitting the database. Closes CLO-745. Release Notes: - N/A --- crates/cloud_api_types/src/internal_api.rs | 11 +++++++++++ crates/collab/src/services/user_service.rs | 23 ++++++++++++++++------ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/crates/cloud_api_types/src/internal_api.rs b/crates/cloud_api_types/src/internal_api.rs index ad3b4557fc..2beda5665a 100644 --- a/crates/cloud_api_types/src/internal_api.rs +++ b/crates/cloud_api_types/src/internal_api.rs @@ -30,3 +30,14 @@ pub struct LookUpUserByGithubLoginBody { pub struct LookUpUserByGithubLoginResponse { pub user: Option, } + +#[derive(Debug, Serialize, Deserialize)] +pub struct FuzzySearchUsersBody { + pub query: String, + pub limit: u32, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct FuzzySearchUsersResponse { + pub users: Vec, +} diff --git a/crates/collab/src/services/user_service.rs b/crates/collab/src/services/user_service.rs index 1f589213d5..becb6dc25c 100644 --- a/crates/collab/src/services/user_service.rs +++ b/crates/collab/src/services/user_service.rs @@ -3,8 +3,8 @@ use std::sync::Arc; use anyhow::{Context as _, anyhow}; use async_trait::async_trait; use cloud_api_types::internal_api::{ - self, LookUpUserByGithubLoginBody, LookUpUserByGithubLoginResponse, LookUpUsersByLegacyIdBody, - LookUpUsersByLegacyIdResponse, + self, FuzzySearchUsersBody, FuzzySearchUsersResponse, LookUpUserByGithubLoginBody, + LookUpUserByGithubLoginResponse, LookUpUsersByLegacyIdBody, LookUpUsersByLegacyIdResponse, }; use reqwest::RequestBuilder; use rpc::proto; @@ -74,7 +74,7 @@ impl UserService for TransitionalUserService { } async fn fuzzy_search_users(&self, query: &str, limit: u32) -> Result> { - self.database_user_service + self.cloud_user_service .fuzzy_search_users(query, limit) .await } @@ -182,10 +182,21 @@ impl UserService for CloudUserService { } async fn fuzzy_search_users(&self, query: &str, limit: u32) -> Result> { - let _ = query; - let _ = limit; + let response_body: FuzzySearchUsersResponse = self + .send_request( + self.http_client + .post(format!( + "{}/internal/users/fuzzy_search", + &self.zed_cloud_url + )) + .json(&FuzzySearchUsersBody { + query: query.to_string(), + limit, + }), + ) + .await?; - unimplemented!("not yet implemented in Cloud") + Ok(response_body.users.into_iter().map(User::from).collect()) } async fn search_channel_members(