From 93b96c7af5870279a4921aadb1d061040e78c82e Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Fri, 20 Oct 2023 15:11:31 +0200 Subject: [PATCH] fmt --- crates/api_common/src/request.rs | 21 +++++++++------------ crates/apub/src/objects/mod.rs | 7 ++----- src/lib.rs | 6 +++--- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/crates/api_common/src/request.rs b/crates/api_common/src/request.rs index 7dc0c3a30..0064c8045 100644 --- a/crates/api_common/src/request.rs +++ b/crates/api_common/src/request.rs @@ -290,17 +290,16 @@ async fn is_image_content_type(client: &ClientWithMiddleware, url: &Url) -> Resu } pub fn client_builder(settings: &Settings) -> ClientBuilder { - let user_agent = - format!( - "Lemmy/{}; +{}", - VERSION, - settings.get_protocol_and_hostname() - ); + let user_agent = format!( + "Lemmy/{}; +{}", + VERSION, + settings.get_protocol_and_hostname() + ); Client::builder() - .user_agent(user_agent.clone()) - .timeout(REQWEST_TIMEOUT) - .connect_timeout(REQWEST_TIMEOUT) + .user_agent(user_agent.clone()) + .timeout(REQWEST_TIMEOUT) + .connect_timeout(REQWEST_TIMEOUT) } #[cfg(test)] @@ -316,9 +315,7 @@ mod tests { #[tokio::test] async fn test_site_metadata() { let settings = &SETTINGS.clone(); - let client = client_builder(settings).build() - .unwrap() - .into(); + let client = client_builder(settings).build().unwrap().into(); let sample_url = Url::parse("https://gitlab.com/IzzyOnDroid/repo/-/wikis/FAQ").unwrap(); let sample_res = fetch_site_metadata(&client, &sample_url).await.unwrap(); assert_eq!( diff --git a/crates/apub/src/objects/mod.rs b/crates/apub/src/objects/mod.rs index 1549892ed..116c7f4fb 100644 --- a/crates/apub/src/objects/mod.rs +++ b/crates/apub/src/objects/mod.rs @@ -59,13 +59,12 @@ pub(crate) mod tests { use activitypub_federation::config::{Data, FederationConfig}; use anyhow::anyhow; - use lemmy_api_common::{context::LemmyContext}; + use lemmy_api_common::{context::LemmyContext, request::client_builder}; use lemmy_db_schema::{source::secret::Secret, utils::build_db_pool_for_tests}; use lemmy_utils::{rate_limit::RateLimitCell, settings::SETTINGS}; use reqwest::{Request, Response}; use reqwest_middleware::{ClientBuilder, Middleware, Next}; use task_local_extensions::Extensions; - use lemmy_api_common::request::client_builder; struct BlockedMiddleware; @@ -87,9 +86,7 @@ pub(crate) mod tests { // call this to run migrations let pool = build_db_pool_for_tests().await; - let client = client_builder(&SETTINGS) - .build() - .unwrap(); + let client = client_builder(&SETTINGS).build().unwrap(); let client = ClientBuilder::new(client).with(BlockedMiddleware).build(); let secret = Secret { diff --git a/src/lib.rs b/src/lib.rs index 4d4c732b8..c12281cdf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -28,6 +28,7 @@ use clap::{ArgAction, Parser}; use lemmy_api_common::{ context::LemmyContext, lemmy_db_views::structs::SiteView, + request::client_builder, send_activity::{ActivityChannel, MATCH_OUTGOING_ACTIVITIES}, utils::{ check_private_instance_and_federation_enabled, @@ -68,7 +69,6 @@ use { prometheus::default_registry, prometheus_metrics::serve_prometheus, }; -use lemmy_api_common::request::client_builder; #[derive(Parser, Debug)] #[command( @@ -202,8 +202,8 @@ pub async fn start_lemmy_server(args: CmdArgs) -> Result<(), LemmyError> { // Pictrs cannot use proxy let pictrs_client = ClientBuilder::new(client_builder(&SETTINGS).no_proxy().build()?) - .with(TracingMiddleware::default()) - .build(); + .with(TracingMiddleware::default()) + .build(); Some(create_http_server( federation_config.clone(), SETTINGS.clone(),