resolve couple pedantic clippy lints, remove unnecessary qualifications

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-03-22 21:51:21 -04:00 committed by June
parent 6d7ef80aba
commit 9d0b647911
35 changed files with 127 additions and 148 deletions

View file

@ -45,17 +45,20 @@ impl Service {
async fn typings_maintain(&self, room_id: &RoomId) -> Result<()> {
let current_timestamp = utils::millis_since_unix_epoch();
let mut removable = Vec::new();
{
let typing = self.typing.read().await;
let Some(room) = typing.get(room_id) else {
return Ok(());
};
for (user, timeout) in room {
if *timeout < current_timestamp {
removable.push(user.clone());
}
}
drop(typing)
drop(typing);
};
if !removable.is_empty() {

View file

@ -1491,14 +1491,13 @@ impl Service {
let permit =
services().globals.servername_ratelimiter.read().await.get(origin).map(|s| Arc::clone(s).acquire_owned());
let permit = match permit {
Some(p) => p,
None => {
let mut write = services().globals.servername_ratelimiter.write().await;
let s = Arc::clone(write.entry(origin.to_owned()).or_insert_with(|| Arc::new(Semaphore::new(1))));
let permit = if let Some(p) = permit {
p
} else {
let mut write = services().globals.servername_ratelimiter.write().await;
let s = Arc::clone(write.entry(origin.to_owned()).or_insert_with(|| Arc::new(Semaphore::new(1))));
s.acquire_owned()
},
s.acquire_owned()
}
.await;

View file

@ -68,7 +68,7 @@ impl Service {
})
})
.take(limit)
.filter_map(std::result::Result::ok) // Filter out buggy events
.filter_map(Result::ok) // Filter out buggy events
.filter(|(_, pdu)| {
services()
.rooms
@ -113,7 +113,7 @@ impl Service {
})
})
.take(limit)
.filter_map(std::result::Result::ok) // Filter out buggy events
.filter_map(Result::ok) // Filter out buggy events
.filter(|(_, pdu)| {
services()
.rooms

View file

@ -109,7 +109,7 @@ impl Arena {
if let Some(next) = self.next_sibling(current) {
current = next;
} else if let Some(parent) = self.parent(current) {
current = parent
current = parent;
} else {
break;
}
@ -148,7 +148,7 @@ impl Arena {
)];
while let Some(parent) = self.parent(parents.last().expect("Has at least one value, as above").0) {
parents.push((parent, self.get(parent).expect("It is some, as above").room_id.clone()))
parents.push((parent, self.get(parent).expect("It is some, as above").room_id.clone()));
}
// If at max_depth, don't add new rooms
@ -607,9 +607,9 @@ impl Service {
arena.push(current_room, children);
if left_to_skip > 0 {
left_to_skip -= 1
left_to_skip -= 1;
} else {
results.push(summary_to_chunk(*summary.clone()))
results.push(summary_to_chunk(*summary.clone()));
}
}
} else {

View file

@ -111,7 +111,7 @@ impl Service {
.rooms
.state_cache
.room_members(room_id)
.filter_map(std::result::Result::ok)
.filter_map(Result::ok)
.filter(|member| member.server_name() == origin);
let visibility = match history_visibility {

View file

@ -37,6 +37,7 @@ use super::state_compressor::CompressedStateEvent;
use crate::{
api::server_server,
service::{
self,
appservice::NamespaceRegex,
pdu::{EventHash, PduBuilder},
},
@ -476,7 +477,7 @@ impl Service {
// the administrator can execute commands as conduit
let from_conduit = pdu.sender == server_user && services().globals.emergency_password().is_none();
if let Some(admin_room) = services().admin.get_admin_room()? {
if let Some(admin_room) = service::admin::Service::get_admin_room()? {
if to_conduit && !from_conduit && admin_room == pdu.room_id {
services().admin.process_message(body, pdu.event_id.clone());
}
@ -540,7 +541,7 @@ impl Service {
.rooms
.alias
.local_aliases_for_room(&pdu.room_id)
.filter_map(std::result::Result::ok)
.filter_map(Result::ok)
.any(|room_alias| aliases.is_match(room_alias.as_str()))
};
@ -721,7 +722,7 @@ impl Service {
) -> Result<Arc<EventId>> {
let (pdu, pdu_json) = self.create_hash_and_sign_event(pdu_builder, sender, room_id, state_lock)?;
if let Some(admin_room) = services().admin.get_admin_room()? {
if let Some(admin_room) = service::admin::Service::get_admin_room()? {
if admin_room == room_id {
match pdu.event_type() {
TimelineEventType::RoomEncryption => {
@ -756,7 +757,7 @@ impl Service {
.rooms
.state_cache
.room_members(room_id)
.filter_map(std::result::Result::ok)
.filter_map(Result::ok)
.filter(|m| m.server_name() == server_name)
.filter(|m| m != target)
.count();
@ -782,7 +783,7 @@ impl Service {
.rooms
.state_cache
.room_members(room_id)
.filter_map(std::result::Result::ok)
.filter_map(Result::ok)
.filter(|m| m.server_name() == server_name)
.filter(|m| m != target)
.count();
@ -821,7 +822,7 @@ impl Service {
services().rooms.state.set_room_state(room_id, statehashid, state_lock)?;
let mut servers: HashSet<OwnedServerName> =
services().rooms.state_cache.room_servers(room_id).filter_map(std::result::Result::ok).collect();
services().rooms.state_cache.room_servers(room_id).filter_map(Result::ok).collect();
// In case we are kicking or banning a user, we need to inform their server of
// the change