Merge branch 'valkum-master-patch-25423' into 'master'

Make clippy happy (needless-return, etc.)

See merge request famedly/conduit!23
This commit is contained in:
Timo Kösters 2021-03-04 12:35:12 +00:00
commit bd6507eafb
7 changed files with 19 additions and 17 deletions

View file

@ -9,9 +9,10 @@ use trust_dns_resolver::TokioAsyncResolver;
pub const COUNTER: &str = "c";
type WellKnownMap = HashMap<Box<ServerName>, (String, Option<String>)>;
#[derive(Clone)]
pub struct Globals {
pub actual_destination_cache: Arc<RwLock<HashMap<Box<ServerName>, (String, Option<String>)>>>, // actual_destination, host
pub actual_destination_cache: Arc<RwLock<WellKnownMap>>, // actual_destination, host
pub(super) globals: sled::Tree,
config: Config,
keypair: Arc<ruma::signatures::Ed25519KeyPair>,

View file

@ -183,7 +183,7 @@ impl Rooms {
)))
})
} else {
return Ok(None);
Ok(None)
}
}
@ -449,6 +449,7 @@ impl Rooms {
///
/// By this point the incoming event should be fully authenticated, no auth happens
/// in `append_pdu`.
#[allow(clippy::too_many_arguments)]
pub fn append_pdu(
&self,
pdu: &PduEvent,
@ -970,7 +971,7 @@ impl Rooms {
.get("users")
.and_then(|users| users.as_sequence())
.map_or_else(
|| Vec::new(),
Vec::new,
|users| {
users
.iter()
@ -1002,7 +1003,7 @@ impl Rooms {
.and_then(|string| {
UserId::parse_with_server_name(string, globals.server_name()).ok()
});
#[allow(clippy::blocks_in_if_conditions)]
if bridge_user_id.map_or(false, |bridge_user_id| {
self.is_joined(&bridge_user_id, room_id).unwrap_or(false)
}) || users.iter().any(|users| {

View file

@ -102,7 +102,7 @@ impl Sending {
match response {
Ok((server, is_appservice)) => {
let mut prefix = if is_appservice {
"+".as_bytes().to_vec()
b"+".to_vec()
} else {
Vec::new()
};
@ -148,7 +148,7 @@ impl Sending {
Err((server, is_appservice, e)) => {
info!("Couldn't send transaction to {}\n{}", server, e);
let mut prefix = if is_appservice {
"+".as_bytes().to_vec()
b"+".to_vec()
} else {
Vec::new()
};
@ -180,7 +180,7 @@ impl Sending {
.map_err(|_| Error::bad_database("ServerName in servernamepduid bytes are invalid."))
.map(|server_str| {
// Appservices start with a plus
if server_str.starts_with("+") {
if server_str.starts_with('+') {
(server_str[1..].to_owned(), true)
} else {
(server_str, false)
@ -196,6 +196,7 @@ impl Sending {
.map(|pdu_id| (server, is_appservice, pdu_id))
)
.filter(|(server, is_appservice, _)| {
#[allow(clippy::blocks_in_if_conditions)]
if last_failed_try.get(server).map_or(false, |(tries, instant)| {
// Fail if a request has failed recently (exponential backoff)
let mut min_elapsed_duration = Duration::from_secs(60) * *tries * *tries;
@ -209,7 +210,7 @@ impl Sending {
}
let mut prefix = if *is_appservice {
"+".as_bytes().to_vec()
b"+".to_vec()
} else {
Vec::new()
};
@ -247,7 +248,7 @@ impl Sending {
#[tracing::instrument(skip(self))]
pub fn send_pdu_appservice(&self, appservice_id: &str, pdu_id: &[u8]) -> Result<()> {
let mut key = "+".as_bytes().to_vec();
let mut key = b"+".to_vec();
key.extend_from_slice(appservice_id.as_bytes());
key.push(0xff);
key.extend_from_slice(pdu_id);
@ -385,7 +386,7 @@ impl Sending {
})?;
// Appservices start with a plus
let (server, is_appservice) = if server.starts_with("+") {
let (server, is_appservice) = if server.starts_with('+') {
(&server[1..], true)
} else {
(&*server, false)