From: Dessalines Date: Wed, 2 Nov 2022 12:10:40 +0000 (-0400) Subject: Fix local site images. (#2519) X-Git-Url: http://these/git/ui/assets/static/%7Bthis.state.url%7D?a=commitdiff_plain;h=ed9e91345a590374b568abefe8cdfedda03191cc;p=lemmy.git Fix local site images. (#2519) * Fix local site images. * It should be set up. --- diff --git a/crates/routes/src/images.rs b/crates/routes/src/images.rs index 78b5a854..59a55fde 100644 --- a/crates/routes/src/images.rs +++ b/crates/routes/src/images.rs @@ -12,7 +12,7 @@ use actix_web::{ }; use futures::stream::{Stream, StreamExt}; use lemmy_api_common::utils::{blocking, get_local_user_view_from_jwt}; -use lemmy_db_schema::source::site::Site; +use lemmy_db_schema::source::local_site::LocalSite; use lemmy_utils::{claims::Claims, rate_limit::RateLimit, REQWEST_TIMEOUT}; use lemmy_websocket::LemmyContext; use reqwest::Body; @@ -126,20 +126,20 @@ async fn full_res( context: web::Data, ) -> Result { // block access to images if instance is private and unauthorized, public - let site = blocking(context.pool(), Site::read_local_site).await?; + let local_site = blocking(context.pool(), LocalSite::read) + .await? + .map_err(error::ErrorBadRequest)?; // The site might not be set up yet - if let Ok(site) = site { - if site.private_instance { - let jwt = req - .cookie("jwt") - .expect("No auth header for picture access"); - if get_local_user_view_from_jwt(jwt.value(), context.pool(), context.secret()) - .await - .is_err() - { - return Ok(HttpResponse::Unauthorized().finish()); - }; - } + if local_site.private_instance { + let jwt = req + .cookie("jwt") + .expect("No auth header for picture access"); + if get_local_user_view_from_jwt(jwt.value(), context.pool(), context.secret()) + .await + .is_err() + { + return Ok(HttpResponse::Unauthorized().finish()); + }; } let name = &filename.into_inner();