fix: ensure limit is always at least 1 when sent to database
This commit is contained in:
@@ -95,7 +95,7 @@ impl AbstractMessages for MongoDb {
|
|||||||
COL,
|
COL,
|
||||||
older_message_filter,
|
older_message_filter,
|
||||||
FindOptions::builder()
|
FindOptions::builder()
|
||||||
.limit(limit / 2)
|
.limit(limit / 2 + 1)
|
||||||
.sort(doc! {
|
.sort(doc! {
|
||||||
"_id": -1_i32
|
"_id": -1_i32
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -280,7 +280,7 @@ auto_derived!(
|
|||||||
pub struct OptionsQueryMessages {
|
pub struct OptionsQueryMessages {
|
||||||
/// Maximum number of messages to fetch
|
/// Maximum number of messages to fetch
|
||||||
///
|
///
|
||||||
/// For fetching nearby messages, this is \`(limit + 1)\`.
|
/// For fetching nearby messages, this is \`(limit + 2)\`.
|
||||||
#[cfg_attr(feature = "validator", validate(range(min = 1, max = 100)))]
|
#[cfg_attr(feature = "validator", validate(range(min = 1, max = 100)))]
|
||||||
pub limit: Option<i64>,
|
pub limit: Option<i64>,
|
||||||
/// Message id before which messages should be fetched
|
/// Message id before which messages should be fetched
|
||||||
|
|||||||
Reference in New Issue
Block a user