Add ReadyBoolExt special case for ReadyEqExt.
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
@@ -50,7 +50,7 @@ use tuwunel_core::{
|
||||
trace,
|
||||
utils::{
|
||||
self, BoolExt, FutureBoolExt, IterStream, ReadyExt, TryFutureExtExt,
|
||||
future::{OptionStream, ReadyEqExt},
|
||||
future::{OptionStream, ReadyBoolExt},
|
||||
math::ruma_from_u64,
|
||||
result::MapExpect,
|
||||
stream::{BroadbandExt, Tools, TryExpect, WidebandExt},
|
||||
@@ -539,7 +539,7 @@ async fn handle_left_room(
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
let is_not_found = services.metadata.exists(room_id).eq(&false);
|
||||
let is_not_found = services.metadata.exists(room_id).is_false();
|
||||
|
||||
let is_disabled = services.metadata.is_disabled(room_id);
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ use tuwunel_core::{
|
||||
is_equal_to, is_true,
|
||||
utils::{
|
||||
BoolExt, FutureBoolExt, IterStream, ReadyExt,
|
||||
future::{self, OptionExt, ReadyEqExt},
|
||||
future::{self, OptionExt, ReadyBoolExt},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -132,7 +132,7 @@ pub(super) async fn filter_room_meta(
|
||||
SyncInfo { services, sender_user, .. }: SyncInfo<'_>,
|
||||
room_id: &RoomId,
|
||||
) -> bool {
|
||||
let not_exists = services.metadata.exists(room_id).eq(&false);
|
||||
let not_exists = services.metadata.exists(room_id).is_false();
|
||||
|
||||
let is_disabled = services.metadata.is_disabled(room_id);
|
||||
|
||||
@@ -141,13 +141,13 @@ pub(super) async fn filter_room_meta(
|
||||
let not_visible = services
|
||||
.state_accessor
|
||||
.user_can_see_state_events(sender_user, room_id)
|
||||
.eq(&false);
|
||||
.is_false();
|
||||
|
||||
pin_mut!(not_visible, not_exists, is_disabled, is_banned);
|
||||
not_visible
|
||||
.or(not_exists)
|
||||
.or(is_disabled)
|
||||
.or(is_banned)
|
||||
.is_false()
|
||||
.await
|
||||
.eq(&false)
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ mod bool_ext;
|
||||
mod ext_ext;
|
||||
mod option_ext;
|
||||
mod option_stream;
|
||||
mod ready_bool_ext;
|
||||
mod ready_eq_ext;
|
||||
mod try_ext_ext;
|
||||
|
||||
@@ -10,6 +11,7 @@ pub use self::{
|
||||
ext_ext::ExtExt,
|
||||
option_ext::OptionExt,
|
||||
option_stream::OptionStream,
|
||||
ready_bool_ext::ReadyBoolExt,
|
||||
ready_eq_ext::ReadyEqExt,
|
||||
try_ext_ext::TryExtExt,
|
||||
};
|
||||
|
||||
18
src/core/utils/future/ready_bool_ext.rs
Normal file
18
src/core/utils/future/ready_bool_ext.rs
Normal file
@@ -0,0 +1,18 @@
|
||||
#![allow(clippy::wrong_self_convention)]
|
||||
|
||||
use futures::Future;
|
||||
|
||||
use super::ReadyEqExt;
|
||||
|
||||
pub trait ReadyBoolExt
|
||||
where
|
||||
Self: Future<Output = bool> + ReadyEqExt<bool> + Send,
|
||||
{
|
||||
#[inline]
|
||||
fn is_false(self) -> impl Future<Output = bool> + Send { self.eq(&false) }
|
||||
|
||||
#[inline]
|
||||
fn is_true(self) -> impl Future<Output = bool> + Send { self.eq(&true) }
|
||||
}
|
||||
|
||||
impl<Fut> ReadyBoolExt for Fut where Fut: Future<Output = bool> + Send {}
|
||||
@@ -13,7 +13,7 @@ use tuwunel_core::{
|
||||
Err, Result, debug_info, debug_warn, err, implement,
|
||||
matrix::PduCount,
|
||||
pdu::PduBuilder,
|
||||
utils::{self, FutureBoolExt, future::ReadyEqExt},
|
||||
utils::{self, FutureBoolExt, future::ReadyBoolExt},
|
||||
warn,
|
||||
};
|
||||
|
||||
@@ -74,13 +74,13 @@ pub async fn leave(
|
||||
.services
|
||||
.state_cache
|
||||
.server_in_room(self.services.globals.server_name(), room_id)
|
||||
.eq(&false);
|
||||
.is_false();
|
||||
|
||||
let not_knocked = self
|
||||
.services
|
||||
.state_cache
|
||||
.is_knocked(user_id, room_id)
|
||||
.eq(&false);
|
||||
.is_false();
|
||||
|
||||
// Ask a remote server if we don't have this room and are not knocking on it
|
||||
if remote_leave_now || dont_have_room.and(not_knocked).await {
|
||||
|
||||
Reference in New Issue
Block a user