cargo fmt

Signed-off-by: girlbossceo <june@girlboss.ceo>
This commit is contained in:
girlbossceo 2023-07-29 14:30:48 +00:00
parent 3494d7759e
commit d7061e6984
6 changed files with 31 additions and 22 deletions

View file

@ -425,13 +425,10 @@ pub async fn get_room_event_route(
) -> Result<get_room_event::v3::Response> { ) -> Result<get_room_event::v3::Response> {
let sender_user = body.sender_user.as_ref().expect("user is authenticated"); let sender_user = body.sender_user.as_ref().expect("user is authenticated");
let event = services() let event = services().rooms.timeline.get_pdu(&body.event_id)?.ok_or({
.rooms warn!("Event not found, event ID: {:?}", &body.event_id);
.timeline Error::BadRequest(ErrorKind::NotFound, "Event not found.")
.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( if !services().rooms.state_accessor.user_can_see_event(
sender_user, sender_user,

View file

@ -131,10 +131,12 @@ pub async fn get_state_events_for_key_route(
.state_accessor .state_accessor
.room_state_get(&body.room_id, &body.event_type, &body.state_key)? .room_state_get(&body.room_id, &body.event_type, &body.state_key)?
.ok_or({ .ok_or({
warn!("State event {:?} not found in room {:?}", &body.event_type, &body.room_id); warn!(
Error::BadRequest(ErrorKind::NotFound, "State event {:?} not found in room {:?}",
"State event not found.", &body.event_type, &body.room_id
)})?; );
Error::BadRequest(ErrorKind::NotFound, "State event not found.")
})?;
Ok(get_state_events_for_key::v3::Response { Ok(get_state_events_for_key::v3::Response {
content: serde_json::from_str(event.content.get()) content: serde_json::from_str(event.content.get())
@ -168,9 +170,12 @@ pub async fn get_state_events_for_empty_key_route(
.state_accessor .state_accessor
.room_state_get(&body.room_id, &body.event_type, "")? .room_state_get(&body.room_id, &body.event_type, "")?
.ok_or({ .ok_or({
warn!("State event {:?} not found in room {:?}", &body.event_type, &body.room_id); warn!(
Error::BadRequest(ErrorKind::NotFound, "State event {:?} not found in room {:?}",
"State event not found.",)})?; &body.event_type, &body.room_id
);
Error::BadRequest(ErrorKind::NotFound, "State event not found.")
})?;
Ok(get_state_events_for_key::v3::Response { Ok(get_state_events_for_key::v3::Response {
content: serde_json::from_str(event.content.get()) content: serde_json::from_str(event.content.get())

View file

@ -955,7 +955,8 @@ pub async fn get_event_route(
.get_pdu_json(&body.event_id)? .get_pdu_json(&body.event_id)?
.ok_or({ .ok_or({
warn!("Event not found, event ID: {:?}", &body.event_id); 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 let room_id_str = event
.get("room_id") .get("room_id")
@ -1197,7 +1198,8 @@ pub async fn get_event_authorization_route(
.get_pdu_json(&body.event_id)? .get_pdu_json(&body.event_id)?
.ok_or({ .ok_or({
warn!("Event not found, event ID: {:?}", &body.event_id); 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 let room_id_str = event
.get("room_id") .get("room_id")

View file

@ -1,8 +1,8 @@
mod data; mod data;
pub use data::Data; pub use data::Data;
use ruma::serde::Base64;
use ruma::{ use ruma::{
OwnedDeviceId, OwnedEventId, OwnedRoomId, OwnedServerName, OwnedServerSigningKeyId, OwnedUserId, serde::Base64, OwnedDeviceId, OwnedEventId, OwnedRoomId, OwnedServerName,
OwnedServerSigningKeyId, OwnedUserId,
}; };
use crate::api::server_server::FedDest; use crate::api::server_server::FedDest;
@ -15,14 +15,16 @@ use ruma::{
}, },
DeviceId, RoomVersionId, ServerName, UserId, DeviceId, RoomVersionId, ServerName, UserId,
}; };
use std::sync::atomic::{self, AtomicBool};
use std::{ use std::{
collections::{BTreeMap, HashMap}, collections::{BTreeMap, HashMap},
fs, fs,
future::Future, future::Future,
net::{IpAddr, SocketAddr}, net::{IpAddr, SocketAddr},
path::PathBuf, path::PathBuf,
sync::{Arc, Mutex, RwLock}, sync::{
atomic::{self, AtomicBool},
Arc, Mutex, RwLock,
},
time::{Duration, Instant}, time::{Duration, Instant},
}; };
use tokio::sync::{broadcast, watch::Receiver, Mutex as TokioMutex, Semaphore}; use tokio::sync::{broadcast, watch::Receiver, Mutex as TokioMutex, Semaphore};

View file

@ -344,7 +344,8 @@ impl Service {
.map(|create_event| create_event.room_version) .map(|create_event| create_event.room_version)
.ok_or({ .ok_or({
warn!("Invalid room version for room {room_id}"); warn!("Invalid room version for room {room_id}");
Error::BadDatabase("Invalid room version")})?; Error::BadDatabase("Invalid room version")
})?;
Ok(room_version) Ok(room_version)
} }

View file

@ -62,7 +62,9 @@ impl Service {
device_id: OwnedDeviceId, device_id: OwnedDeviceId,
request: &mut sync_events::v4::Request, request: &mut sync_events::v4::Request,
) -> BTreeMap<String, BTreeMap<OwnedRoomId, bool>> { ) -> BTreeMap<String, BTreeMap<OwnedRoomId, bool>> {
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 cache = &mut self.connections.lock().unwrap();
let cached = Arc::clone( let cached = Arc::clone(