From d7061e69841526f16d33b3c6739ef8c853d777b9 Mon Sep 17 00:00:00 2001 From: girlbossceo Date: Sat, 29 Jul 2023 14:30:48 +0000 Subject: [PATCH] cargo fmt Signed-off-by: girlbossceo --- src/api/client_server/room.rs | 11 ++++------- src/api/client_server/state.rs | 19 ++++++++++++------- src/api/server_server.rs | 6 ++++-- src/service/globals/mod.rs | 10 ++++++---- src/service/rooms/state/mod.rs | 3 ++- src/service/users/mod.rs | 4 +++- 6 files changed, 31 insertions(+), 22 deletions(-) diff --git a/src/api/client_server/room.rs b/src/api/client_server/room.rs index 7bdccae..5c98028 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 5ea7e99..6a37489 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 95716e7..8c54e92 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 7d61829..44235b3 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 48e3d79..9790695 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 f5b914f..38aca80 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(