mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-09 09:52:10 +00:00
fmt
This commit is contained in:
parent
9184800582
commit
93b96c7af5
|
@ -290,17 +290,16 @@ async fn is_image_content_type(client: &ClientWithMiddleware, url: &Url) -> Resu
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn client_builder(settings: &Settings) -> ClientBuilder {
|
pub fn client_builder(settings: &Settings) -> ClientBuilder {
|
||||||
let user_agent =
|
let user_agent = format!(
|
||||||
format!(
|
"Lemmy/{}; +{}",
|
||||||
"Lemmy/{}; +{}",
|
VERSION,
|
||||||
VERSION,
|
settings.get_protocol_and_hostname()
|
||||||
settings.get_protocol_and_hostname()
|
);
|
||||||
);
|
|
||||||
|
|
||||||
Client::builder()
|
Client::builder()
|
||||||
.user_agent(user_agent.clone())
|
.user_agent(user_agent.clone())
|
||||||
.timeout(REQWEST_TIMEOUT)
|
.timeout(REQWEST_TIMEOUT)
|
||||||
.connect_timeout(REQWEST_TIMEOUT)
|
.connect_timeout(REQWEST_TIMEOUT)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -316,9 +315,7 @@ mod tests {
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_site_metadata() {
|
async fn test_site_metadata() {
|
||||||
let settings = &SETTINGS.clone();
|
let settings = &SETTINGS.clone();
|
||||||
let client = client_builder(settings).build()
|
let client = client_builder(settings).build().unwrap().into();
|
||||||
.unwrap()
|
|
||||||
.into();
|
|
||||||
let sample_url = Url::parse("https://gitlab.com/IzzyOnDroid/repo/-/wikis/FAQ").unwrap();
|
let sample_url = Url::parse("https://gitlab.com/IzzyOnDroid/repo/-/wikis/FAQ").unwrap();
|
||||||
let sample_res = fetch_site_metadata(&client, &sample_url).await.unwrap();
|
let sample_res = fetch_site_metadata(&client, &sample_url).await.unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|
|
@ -59,13 +59,12 @@ pub(crate) mod tests {
|
||||||
|
|
||||||
use activitypub_federation::config::{Data, FederationConfig};
|
use activitypub_federation::config::{Data, FederationConfig};
|
||||||
use anyhow::anyhow;
|
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_db_schema::{source::secret::Secret, utils::build_db_pool_for_tests};
|
||||||
use lemmy_utils::{rate_limit::RateLimitCell, settings::SETTINGS};
|
use lemmy_utils::{rate_limit::RateLimitCell, settings::SETTINGS};
|
||||||
use reqwest::{Request, Response};
|
use reqwest::{Request, Response};
|
||||||
use reqwest_middleware::{ClientBuilder, Middleware, Next};
|
use reqwest_middleware::{ClientBuilder, Middleware, Next};
|
||||||
use task_local_extensions::Extensions;
|
use task_local_extensions::Extensions;
|
||||||
use lemmy_api_common::request::client_builder;
|
|
||||||
|
|
||||||
struct BlockedMiddleware;
|
struct BlockedMiddleware;
|
||||||
|
|
||||||
|
@ -87,9 +86,7 @@ pub(crate) mod tests {
|
||||||
// call this to run migrations
|
// call this to run migrations
|
||||||
let pool = build_db_pool_for_tests().await;
|
let pool = build_db_pool_for_tests().await;
|
||||||
|
|
||||||
let client = client_builder(&SETTINGS)
|
let client = client_builder(&SETTINGS).build().unwrap();
|
||||||
.build()
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let client = ClientBuilder::new(client).with(BlockedMiddleware).build();
|
let client = ClientBuilder::new(client).with(BlockedMiddleware).build();
|
||||||
let secret = Secret {
|
let secret = Secret {
|
||||||
|
|
|
@ -28,6 +28,7 @@ use clap::{ArgAction, Parser};
|
||||||
use lemmy_api_common::{
|
use lemmy_api_common::{
|
||||||
context::LemmyContext,
|
context::LemmyContext,
|
||||||
lemmy_db_views::structs::SiteView,
|
lemmy_db_views::structs::SiteView,
|
||||||
|
request::client_builder,
|
||||||
send_activity::{ActivityChannel, MATCH_OUTGOING_ACTIVITIES},
|
send_activity::{ActivityChannel, MATCH_OUTGOING_ACTIVITIES},
|
||||||
utils::{
|
utils::{
|
||||||
check_private_instance_and_federation_enabled,
|
check_private_instance_and_federation_enabled,
|
||||||
|
@ -68,7 +69,6 @@ use {
|
||||||
prometheus::default_registry,
|
prometheus::default_registry,
|
||||||
prometheus_metrics::serve_prometheus,
|
prometheus_metrics::serve_prometheus,
|
||||||
};
|
};
|
||||||
use lemmy_api_common::request::client_builder;
|
|
||||||
|
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
#[command(
|
#[command(
|
||||||
|
@ -202,8 +202,8 @@ pub async fn start_lemmy_server(args: CmdArgs) -> Result<(), LemmyError> {
|
||||||
|
|
||||||
// Pictrs cannot use proxy
|
// Pictrs cannot use proxy
|
||||||
let pictrs_client = ClientBuilder::new(client_builder(&SETTINGS).no_proxy().build()?)
|
let pictrs_client = ClientBuilder::new(client_builder(&SETTINGS).no_proxy().build()?)
|
||||||
.with(TracingMiddleware::default())
|
.with(TracingMiddleware::default())
|
||||||
.build();
|
.build();
|
||||||
Some(create_http_server(
|
Some(create_http_server(
|
||||||
federation_config.clone(),
|
federation_config.clone(),
|
||||||
SETTINGS.clone(),
|
SETTINGS.clone(),
|
||||||
|
|
Loading…
Reference in a new issue