From c64a474954e4573f0fdeace41c44c29c99dcc086 Mon Sep 17 00:00:00 2001 From: Benjamin Lee Date: Mon, 3 Jun 2024 17:41:11 -0700 Subject: [PATCH] workaround to fix search in element We inherited a similar workaround from conduit, but removed it in 71c48f66c4922813c2dc30b7b875200e06ce4b75. At the time, it was not clear that this had broken search. Fixes: !26 --- src/api/client_server/search.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/api/client_server/search.rs b/src/api/client_server/search.rs index 6e779a18..115b01b9 100644 --- a/src/api/client_server/search.rs +++ b/src/api/client_server/search.rs @@ -11,7 +11,7 @@ use ruma::{ }, }, }, - uint, + uint, UInt, }; use crate::{services, Ar, Error, Ra, Result}; @@ -138,7 +138,13 @@ pub(crate) async fn search_events_route( Ok(Ra(search_events::v3::Response::new(ResultCategories { room_events: ResultRoomEvents { - count: None, + // TODO(compat): this is not a good estimate of the total number of + // results. we should just be returning None, but + // element incorrectly relies on this field. Switch back + // to None when [1] is fixed + // + // [1]: https://github.com/element-hq/element-web/issues/27517 + count: Some(results.len().try_into().unwrap_or(UInt::MAX)), // TODO groups: BTreeMap::new(), next_batch,