X-Git-Url: http://these/git/?a=blobdiff_plain;f=src%2Flib.rs;h=55bb91606341cdbfb8c4747cea93a884108c97fc;hb=92568956353f21649ed9aff68b42699c9d036f30;hp=b6fd64ec8096c0640549774339bf11bbc1553cbc;hpb=b35757b429e015fa5705ac07ea6993342f675761;p=lemmy.git diff --git a/src/lib.rs b/src/lib.rs index b6fd64ec..55bb9160 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,7 +10,13 @@ pub mod telemetry; use crate::{code_migrations::run_advanced_migrations, root_span_builder::QuieterRootSpanBuilder}; use activitypub_federation::config::{FederationConfig, FederationMiddleware}; use actix_cors::Cors; -use actix_web::{middleware, web::Data, App, HttpServer, Result}; +use actix_web::{ + middleware::{self, ErrorHandlers}, + web::Data, + App, + HttpServer, + Result, +}; use lemmy_api_common::{ context::LemmyContext, lemmy_db_views::structs::SiteView, @@ -29,6 +35,7 @@ use lemmy_routes::{feeds, images, nodeinfo, webfinger}; use lemmy_utils::{ error::LemmyError, rate_limit::RateLimitCell, + response::jsonify_plain_text_errors, settings::SETTINGS, SYNCHRONOUS_FEDERATION, }; @@ -68,15 +75,15 @@ pub async fn start_lemmy_server() -> Result<(), LemmyError> { let pool = build_db_pool(&settings).await?; // Run the Code-required migrations - run_advanced_migrations(&pool, &settings).await?; + run_advanced_migrations(&mut (&pool).into(), &settings).await?; // Initialize the secrets - let secret = Secret::init(&pool) + let secret = Secret::init(&mut (&pool).into()) .await .expect("Couldn't initialize secrets."); // Make sure the local site is set up. - let site_view = SiteView::read_local(&pool) + let site_view = SiteView::read_local(&mut (&pool).into()) .await .expect("local site not set up"); let local_site = site_view.local_site; @@ -146,7 +153,7 @@ pub async fn start_lemmy_server() -> Result<(), LemmyError> { .retry_count(settings.retry_count) .debug(*SYNCHRONOUS_FEDERATION) .http_signature_compat(true) - .url_verifier(Box::new(VerifyUrlData(context.pool().clone()))) + .url_verifier(Box::new(VerifyUrlData(context.inner_pool().clone()))) .build() .await?; @@ -156,7 +163,7 @@ pub async fn start_lemmy_server() -> Result<(), LemmyError> { let prom_api_metrics = PrometheusMetricsBuilder::new("lemmy_api") .registry(default_registry().clone()) .build() - .unwrap(); + .expect("Should always be buildable"); // Create Http server with websocket support HttpServer::new(move || { @@ -181,6 +188,7 @@ pub async fn start_lemmy_server() -> Result<(), LemmyError> { .wrap(middleware::Compress::default()) .wrap(cors_config) .wrap(TracingLogger::::new()) + .wrap(ErrorHandlers::new().default_handler(jsonify_plain_text_errors)) .app_data(Data::new(context.clone())) .app_data(Data::new(rate_limit_cell.clone())) .wrap(FederationMiddleware::new(federation_config.clone()));