diff --git a/src/api/client_server/room.rs b/src/api/client_server/room.rs index 7bdccae1..5c98028d 100644 --- a/src/api/client_server/room.rs +++ b/src/api/client_server/room.rs @@ -425,13 +425,10 @@ pub async fn get_room_event_route( ) -> Result { let sender_user = body.sender_user.as_ref().expect("user is authenticated"); - let event = services() - .rooms - .timeline - .get_pdu(&body.event_id)? - .ok_or({ - warn!("Event not found, event ID: {:?}", &body.event_id); - Error::BadRequest(ErrorKind::NotFound, "Event not found.")})?; + let event = services().rooms.timeline.get_pdu(&body.event_id)?.ok_or({ + warn!("Event not found, event ID: {:?}", &body.event_id); + Error::BadRequest(ErrorKind::NotFound, "Event not found.") + })?; if !services().rooms.state_accessor.user_can_see_event( sender_user, diff --git a/src/api/client_server/state.rs b/src/api/client_server/state.rs index 5ea7e998..6a374893 100644 --- a/src/api/client_server/state.rs +++ b/src/api/client_server/state.rs @@ -131,10 +131,12 @@ pub async fn get_state_events_for_key_route( .state_accessor .room_state_get(&body.room_id, &body.event_type, &body.state_key)? .ok_or({ - warn!("State event {:?} not found in room {:?}", &body.event_type, &body.room_id); - Error::BadRequest(ErrorKind::NotFound, - "State event not found.", - )})?; + warn!( + "State event {:?} not found in room {:?}", + &body.event_type, &body.room_id + ); + Error::BadRequest(ErrorKind::NotFound, "State event not found.") + })?; Ok(get_state_events_for_key::v3::Response { content: serde_json::from_str(event.content.get()) @@ -168,9 +170,12 @@ pub async fn get_state_events_for_empty_key_route( .state_accessor .room_state_get(&body.room_id, &body.event_type, "")? .ok_or({ - warn!("State event {:?} not found in room {:?}", &body.event_type, &body.room_id); - Error::BadRequest(ErrorKind::NotFound, - "State event not found.",)})?; + warn!( + "State event {:?} not found in room {:?}", + &body.event_type, &body.room_id + ); + Error::BadRequest(ErrorKind::NotFound, "State event not found.") + })?; Ok(get_state_events_for_key::v3::Response { content: serde_json::from_str(event.content.get()) diff --git a/src/api/server_server.rs b/src/api/server_server.rs index 95716e72..8c54e92f 100644 --- a/src/api/server_server.rs +++ b/src/api/server_server.rs @@ -955,7 +955,8 @@ pub async fn get_event_route( .get_pdu_json(&body.event_id)? .ok_or({ warn!("Event not found, event ID: {:?}", &body.event_id); - Error::BadRequest(ErrorKind::NotFound, "Event not found.")})?; + Error::BadRequest(ErrorKind::NotFound, "Event not found.") + })?; let room_id_str = event .get("room_id") @@ -1197,7 +1198,8 @@ pub async fn get_event_authorization_route( .get_pdu_json(&body.event_id)? .ok_or({ warn!("Event not found, event ID: {:?}", &body.event_id); - Error::BadRequest(ErrorKind::NotFound, "Event not found.")})?; + Error::BadRequest(ErrorKind::NotFound, "Event not found.") + })?; let room_id_str = event .get("room_id") diff --git a/src/service/globals/mod.rs b/src/service/globals/mod.rs index 7d618298..44235b31 100644 --- a/src/service/globals/mod.rs +++ b/src/service/globals/mod.rs @@ -1,8 +1,8 @@ mod data; pub use data::Data; -use ruma::serde::Base64; use ruma::{ - OwnedDeviceId, OwnedEventId, OwnedRoomId, OwnedServerName, OwnedServerSigningKeyId, OwnedUserId, + serde::Base64, OwnedDeviceId, OwnedEventId, OwnedRoomId, OwnedServerName, + OwnedServerSigningKeyId, OwnedUserId, }; use crate::api::server_server::FedDest; @@ -15,14 +15,16 @@ use ruma::{ }, DeviceId, RoomVersionId, ServerName, UserId, }; -use std::sync::atomic::{self, AtomicBool}; use std::{ collections::{BTreeMap, HashMap}, fs, future::Future, net::{IpAddr, SocketAddr}, path::PathBuf, - sync::{Arc, Mutex, RwLock}, + sync::{ + atomic::{self, AtomicBool}, + Arc, Mutex, RwLock, + }, time::{Duration, Instant}, }; use tokio::sync::{broadcast, watch::Receiver, Mutex as TokioMutex, Semaphore}; diff --git a/src/service/rooms/state/mod.rs b/src/service/rooms/state/mod.rs index 48e3d791..97906954 100644 --- a/src/service/rooms/state/mod.rs +++ b/src/service/rooms/state/mod.rs @@ -344,7 +344,8 @@ impl Service { .map(|create_event| create_event.room_version) .ok_or({ warn!("Invalid room version for room {room_id}"); - Error::BadDatabase("Invalid room version")})?; + Error::BadDatabase("Invalid room version") + })?; Ok(room_version) } diff --git a/src/service/users/mod.rs b/src/service/users/mod.rs index f5b914f7..38aca80f 100644 --- a/src/service/users/mod.rs +++ b/src/service/users/mod.rs @@ -62,7 +62,9 @@ impl Service { device_id: OwnedDeviceId, request: &mut sync_events::v4::Request, ) -> BTreeMap> { - let Some(conn_id) = request.conn_id.clone() else { return BTreeMap::new(); }; + let Some(conn_id) = request.conn_id.clone() else { + return BTreeMap::new(); + }; let cache = &mut self.connections.lock().unwrap(); let cached = Arc::clone(