fix image search still being accessible when disabled

This commit is contained in:
mat 2024-05-24 00:37:06 +00:00
parent 2285ee611a
commit 85f438ef65
2 changed files with 8 additions and 3 deletions

View File

@ -8,6 +8,7 @@ use std::{
time::{Duration, Instant},
};
use eyre::bail;
use futures::future::join_all;
use maud::PreEscaped;
use once_cell::sync::Lazy;
@ -536,10 +537,13 @@ pub async fn search(
SearchTab::All => {
make_requests(query, progress_tx, start_time, &send_engine_progress_update).await?
}
SearchTab::Images => {
SearchTab::Images if query.config.image_search.enabled.unwrap() => {
make_image_requests(query, progress_tx, start_time, &send_engine_progress_update)
.await?
}
_ => {
bail!("unknown tab");
}
}
Ok(())

View File

@ -13,8 +13,9 @@ pub async fn route(
Query(params): Query<HashMap<String, String>>,
State(config): State<Arc<Config>>,
) -> Response {
let proxy_config = &config.image_search.proxy;
if !proxy_config.enabled.unwrap() {
let image_search_config = &config.image_search;
let proxy_config = &image_search_config.proxy;
if !image_search_config.enabled.unwrap() || !proxy_config.enabled.unwrap() {
return (StatusCode::FORBIDDEN, "Image proxy is disabled").into_response();
};
let url = params.get("url").cloned().unwrap_or_default();