mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-18 00:01:24 +01:00
enable as_conversions lint
There were some very, uh, creative (and inconsistent) ways to convert between numeric types in here...
This commit is contained in:
parent
a78bf8f50b
commit
71c48f66c4
21 changed files with 195 additions and 91 deletions
|
|
@ -2,6 +2,7 @@ use crate::{services, Error, Result, Ruma};
|
|||
use ruma::{
|
||||
api::client::{context::get_context, error::ErrorKind, filter::LazyLoadOptions},
|
||||
events::StateEventType,
|
||||
uint,
|
||||
};
|
||||
use std::collections::HashSet;
|
||||
use tracing::error;
|
||||
|
|
@ -70,7 +71,8 @@ pub(crate) async fn get_context_route(
|
|||
}
|
||||
|
||||
// Use limit with maximum 100
|
||||
let limit = u64::from(body.limit).min(100) as usize;
|
||||
let half_limit =
|
||||
usize::try_from(body.limit.min(uint!(100)) / uint!(2)).expect("0-50 should fit in usize");
|
||||
|
||||
let base_event = base_event.to_room_event();
|
||||
|
||||
|
|
@ -78,7 +80,7 @@ pub(crate) async fn get_context_route(
|
|||
.rooms
|
||||
.timeline
|
||||
.pdus_until(sender_user, &room_id, base_token)?
|
||||
.take(limit / 2)
|
||||
.take(half_limit)
|
||||
.filter_map(|r| r.ok()) // Remove buggy events
|
||||
.filter(|(_, pdu)| {
|
||||
services()
|
||||
|
|
@ -115,7 +117,7 @@ pub(crate) async fn get_context_route(
|
|||
.rooms
|
||||
.timeline
|
||||
.pdus_after(sender_user, &room_id, base_token)?
|
||||
.take(limit / 2)
|
||||
.take(half_limit)
|
||||
.filter_map(|r| r.ok()) // Remove buggy events
|
||||
.filter(|(_, pdu)| {
|
||||
services()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue