1
0
Fork 0
mirror of https://gitlab.com/famedly/conduit.git synced 2024-11-11 20:21:04 +01:00

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> {
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,

View file

@ -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())

View file

@ -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")

View file

@ -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};

View file

@ -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)
}

View file

@ -62,7 +62,9 @@ impl Service {
device_id: OwnedDeviceId,
request: &mut sync_events::v4::Request,
) -> 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 cached = Arc::clone(