Reformat imports and fix clippy warnings

merge-requests/10/merge
Devin Ragotzy 4 years ago committed by Timo Kösters
parent db8a0c5d69
commit 0d69ebdc6c
No known key found for this signature in database
GPG Key ID: 24DA7517711A2BA4

@ -15,13 +15,10 @@ use ruma::{
}, },
}, },
events::{ events::{
room::canonical_alias, room::{
room::guest_access, canonical_alias, guest_access, history_visibility, join_rules, member, message, name,
room::history_visibility, topic,
room::join_rules, },
room::member,
room::name,
room::{message, topic},
EventType, EventType,
}, },
RoomAliasId, RoomId, RoomVersionId, UserId, RoomAliasId, RoomId, RoomVersionId, UserId,

@ -15,9 +15,7 @@ use ruma::{
}, },
federation, federation,
}, },
directory::Filter, directory::{Filter, IncomingFilter, IncomingRoomNetwork, PublicRoomsChunk, RoomNetwork},
directory::RoomNetwork,
directory::{IncomingFilter, IncomingRoomNetwork, PublicRoomsChunk},
events::{ events::{
room::{avatar, canonical_alias, guest_access, history_visibility, name, topic}, room::{avatar, canonical_alias, guest_access, history_visibility, name, topic},
EventType, EventType,

@ -17,15 +17,12 @@ use ruma::{
}, },
federation, federation,
}, },
events::pdu::Pdu, events::{pdu::Pdu, room::member, EventType},
events::{room::member, EventType},
EventId, Raw, RoomId, RoomVersionId, ServerName, UserId, EventId, Raw, RoomId, RoomVersionId, ServerName, UserId,
}; };
use state_res::StateEvent; use state_res::StateEvent;
use std::{ use std::{
collections::BTreeMap, collections::{BTreeMap, HashMap, HashSet},
collections::HashMap,
collections::HashSet,
convert::{TryFrom, TryInto}, convert::{TryFrom, TryInto},
iter, iter,
sync::Arc, sync::Arc,

@ -9,9 +9,8 @@ use ruma::{
}, },
}, },
events::{ events::{
room::history_visibility::HistoryVisibility, room::history_visibility::{HistoryVisibility, HistoryVisibilityEventContent},
room::history_visibility::HistoryVisibilityEventContent, AnyStateEventContent, AnyStateEventContent, EventContent, EventType,
EventContent, EventType,
}, },
EventId, RoomId, UserId, EventId, RoomId, UserId,
}; };
@ -103,6 +102,7 @@ pub async fn get_state_events_route(
) -> ConduitResult<get_state_events::Response> { ) -> ConduitResult<get_state_events::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");
#[allow(clippy::blocks_in_if_conditions)]
// Users not in the room should not be able to access the state unless history_visibility is // Users not in the room should not be able to access the state unless history_visibility is
// WorldReadable // WorldReadable
if !db.rooms.is_joined(sender_user, &body.room_id)? if !db.rooms.is_joined(sender_user, &body.room_id)?
@ -148,6 +148,7 @@ pub async fn get_state_events_for_key_route(
) -> ConduitResult<get_state_events_for_key::Response> { ) -> ConduitResult<get_state_events_for_key::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");
#[allow(clippy::blocks_in_if_conditions)]
// Users not in the room should not be able to access the state unless history_visibility is // Users not in the room should not be able to access the state unless history_visibility is
// WorldReadable // WorldReadable
if !db.rooms.is_joined(sender_user, &body.room_id)? if !db.rooms.is_joined(sender_user, &body.room_id)?
@ -198,6 +199,7 @@ pub async fn get_state_events_for_empty_key_route(
) -> ConduitResult<get_state_events_for_empty_key::Response> { ) -> ConduitResult<get_state_events_for_empty_key::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");
#[allow(clippy::blocks_in_if_conditions)]
// Users not in the room should not be able to access the state unless history_visibility is // Users not in the room should not be able to access the state unless history_visibility is
// WorldReadable // WorldReadable
if !db.rooms.is_joined(sender_user, &body.room_id)? if !db.rooms.is_joined(sender_user, &body.room_id)?

@ -116,6 +116,7 @@ impl Sending {
} }
} }
Err((_server, _e)) => { Err((_server, _e)) => {
log::error!("server: {}\nerror: {}", _server, _e)
// TODO: exponential backoff // TODO: exponential backoff
} }
}; };
@ -131,7 +132,7 @@ impl Sending {
.expect("splitn will always return 1 or more elements"), .expect("splitn will always return 1 or more elements"),
) )
.map_err(|_| Error::bad_database("ServerName in servernamepduid bytes are invalid.")) .map_err(|_| Error::bad_database("ServerName in servernamepduid bytes are invalid."))
.and_then(|server_str|Box::<ServerName>::try_from(server_str) .and_then(|server_str| Box::<ServerName>::try_from(server_str)
.map_err(|_| Error::bad_database("ServerName in servernamepduid is invalid."))) .map_err(|_| Error::bad_database("ServerName in servernamepduid is invalid.")))
.ok() .ok()
.and_then(|server| parts .and_then(|server| parts
@ -162,7 +163,7 @@ impl Sending {
}); });
} }
pub fn send_pdu(&self, server: Box<ServerName>, pdu_id: &[u8]) -> Result<()> { pub fn send_pdu(&self, server: &ServerName, pdu_id: &[u8]) -> Result<()> {
let mut key = server.as_bytes().to_vec(); let mut key = server.as_bytes().to_vec();
key.push(0xff); key.push(0xff);
key.extend_from_slice(pdu_id); key.extend_from_slice(pdu_id);

@ -4,7 +4,10 @@ use ruma::{
identifiers::{DeviceId, UserId}, identifiers::{DeviceId, UserId},
Outgoing, Outgoing,
}; };
use std::{convert::TryFrom, convert::TryInto, ops::Deref}; use std::{
convert::{TryFrom, TryInto},
ops::Deref,
};
#[cfg(feature = "conduit_bin")] #[cfg(feature = "conduit_bin")]
use { use {

@ -89,9 +89,23 @@ pub fn common_elements(
} }
} }
} }
false false
}) })
.all(|b| b) .all(|b| b)
})) }))
} }
#[test]
fn sled_tests() {
let db = sled::Config::new().temporary(true).open().unwrap();
db.insert(1_u64.to_be_bytes(), vec![10]).unwrap();
db.insert(2_u64.to_be_bytes(), vec![20]).unwrap();
db.insert(3_u64.to_be_bytes(), vec![30]).unwrap();
let mut key = 1_u64.to_be_bytes().to_vec();
key.push(1);
db.insert(key, vec![40]).unwrap();
println!("{:?}", db.iter().collect::<Result<Vec<_>, _>>().unwrap())
}

Loading…
Cancel
Save