mirror of
https://gitlab.com/famedly/conduit.git
synced 2024-12-29 05:53:48 +03:00
fix: crash on empty search
This commit is contained in:
parent
f35ad27627
commit
eb0b2c429f
2 changed files with 20 additions and 18 deletions
|
@ -44,11 +44,12 @@ pub async fn search_events_route(
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
let search = db
|
if let Some(search) = db
|
||||||
.rooms
|
.rooms
|
||||||
.search_pdus(&room_id, &search_criteria.search_term)?;
|
.search_pdus(&room_id, &search_criteria.search_term)?
|
||||||
|
{
|
||||||
searches.push(search.0.peekable());
|
searches.push(search.0.peekable());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let skip = match body.next_batch.as_ref().map(|s| s.parse()) {
|
let skip = match body.next_batch.as_ref().map(|s| s.parse()) {
|
||||||
|
|
|
@ -2771,7 +2771,7 @@ impl Rooms {
|
||||||
&'a self,
|
&'a self,
|
||||||
room_id: &RoomId,
|
room_id: &RoomId,
|
||||||
search_string: &str,
|
search_string: &str,
|
||||||
) -> Result<(impl Iterator<Item = Vec<u8>> + 'a, Vec<String>)> {
|
) -> Result<Option<(impl Iterator<Item = Vec<u8>> + 'a, Vec<String>)>> {
|
||||||
let prefix = self
|
let prefix = self
|
||||||
.get_shortroomid(room_id)?
|
.get_shortroomid(room_id)?
|
||||||
.expect("room exists")
|
.expect("room exists")
|
||||||
|
@ -2799,19 +2799,20 @@ impl Rooms {
|
||||||
.map(|(key, _)| key[key.len() - size_of::<u64>()..].to_vec())
|
.map(|(key, _)| key[key.len() - size_of::<u64>()..].to_vec())
|
||||||
});
|
});
|
||||||
|
|
||||||
Ok((
|
Ok(utils::common_elements(iterators, |a, b| {
|
||||||
utils::common_elements(iterators, |a, b| {
|
// We compare b with a because we reversed the iterator earlier
|
||||||
// We compare b with a because we reversed the iterator earlier
|
b.cmp(a)
|
||||||
b.cmp(a)
|
})
|
||||||
})
|
.map(|iter| {
|
||||||
.unwrap()
|
(
|
||||||
.map(move |id| {
|
iter.map(move |id| {
|
||||||
let mut pduid = prefix_clone.clone();
|
let mut pduid = prefix_clone.clone();
|
||||||
pduid.extend_from_slice(&id);
|
pduid.extend_from_slice(&id);
|
||||||
pduid
|
pduid
|
||||||
}),
|
}),
|
||||||
words,
|
words,
|
||||||
))
|
)
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip(self))]
|
#[tracing::instrument(skip(self))]
|
||||||
|
|
Loading…
Reference in a new issue