diff --git a/plume-models/src/config.rs b/plume-models/src/config.rs index 37b3febb..87218057 100644 --- a/plume-models/src/config.rs +++ b/plume-models/src/config.rs @@ -303,9 +303,7 @@ fn get_proxy_config() -> Option { if only_domains.contains(domain) || only_domains .iter() - .filter(|target| domain.ends_with(&format!(".{}", target))) - .next() - .is_some() + .any(|target| domain.ends_with(&format!(".{}", target))) { Some(proxy_url.clone()) } else { @@ -317,7 +315,6 @@ fn get_proxy_config() -> Option { }) } else { reqwest::Proxy::all(proxy_url) - .ok() .expect("Invalid PROXY_URL") }; Some(ProxyConfig { diff --git a/plume-models/src/posts.rs b/plume-models/src/posts.rs index e10c2fc1..e60b4bd7 100644 --- a/plume-models/src/posts.rs +++ b/plume-models/src/posts.rs @@ -123,8 +123,7 @@ impl Post { .filter(posts::published.eq(true)) .count() .load(conn)? - .iter() - .next() + .get(0) .cloned() .ok_or(Error::NotFound) } @@ -287,17 +286,16 @@ impl Post { } pub fn get_receivers_urls(&self, conn: &Connection) -> Result> { - let followers = self - .get_authors(conn)? - .into_iter() - .filter_map(|a| a.get_followers(conn).ok()) - .collect::>>(); - Ok(followers.into_iter().fold(vec![], |mut acc, f| { - for x in f { - acc.push(x.ap_url); - } - acc - })) + Ok(self + .get_authors(conn)? + .into_iter() + .filter_map(|a| a.get_followers(conn).ok()) + .fold(vec![], |mut acc, f| { + for x in f { + acc.push(x.ap_url); + } + acc + })) } pub fn to_activity(&self, conn: &Connection) -> Result { diff --git a/src/routes/medias.rs b/src/routes/medias.rs index 91c64db8..44bf2ba8 100644 --- a/src/routes/medias.rs +++ b/src/routes/medias.rs @@ -45,7 +45,7 @@ pub fn upload( let (_, boundary) = ct .params() .find(|&(k, _)| k == "boundary") - .ok_or_else(|| status::BadRequest(Some("No boundary")))?; + .ok_or(status::BadRequest(Some("No boundary")))?; if let SaveResult::Full(entries) = Multipart::with_body(data.open(), boundary).save().temp() { let fields = entries.fields; @@ -53,7 +53,7 @@ pub fn upload( let filename = fields .get("file") .and_then(|v| v.iter().next()) - .ok_or_else(|| status::BadRequest(Some("No file uploaded")))? + .ok_or(status::BadRequest(Some("No file uploaded")))? .headers .filename .clone();