From 37e158550af6b3b6669e23998d3aa47c617ed020 Mon Sep 17 00:00:00 2001 From: kieran Date: Mon, 16 Dec 2024 13:44:57 +0000 Subject: [PATCH] fix: add legacy route --- src/bin/main.rs | 16 ++++------------ src/routes/mod.rs | 3 ++- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/bin/main.rs b/src/bin/main.rs index ea3aaba..3f1568e 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -18,8 +18,6 @@ use route96::filesystem::FileStore; use route96::routes; use route96::routes::{get_blob, head_blob, root}; use route96::settings::Settings; -#[cfg(feature = "void-cat-redirects")] -use route96::void_db::VoidCatDb; use route96::webhook::Webhook; #[derive(Parser, Debug)] @@ -78,7 +76,10 @@ async fn main() -> Result<(), Error> { ) .attach(CORS) .attach(Shield::new()) // disable - .mount("/", routes![root, get_blob, head_blob]) + .mount( + "/", + routes![root, get_blob, head_blob, routes::void_cat_redirect], + ) .mount("/admin", routes::admin_routes()); #[cfg(feature = "analytics")] @@ -95,15 +96,6 @@ async fn main() -> Result<(), Error> { { rocket = rocket.mount("/", routes::nip96_routes()); } - #[cfg(feature = "void-cat-redirects")] - { - if let Some(conn) = settings.void_cat_database { - let vdb = VoidCatDb::connect(&conn).await?; - rocket = rocket - .mount("/", routes![routes::void_cat_redirect]) - .manage(vdb); - } - } if let Err(e) = rocket.launch().await { error!("Rocker error {}", e); Err(Error::from(e)) diff --git a/src/routes/mod.rs b/src/routes/mod.rs index 0e0fa59..5543b64 100644 --- a/src/routes/mod.rs +++ b/src/routes/mod.rs @@ -9,7 +9,7 @@ use crate::settings::Settings; use crate::void_file::VoidFile; use anyhow::Error; use http_range_header::{parse_range_header, EndPosition, StartPosition}; -use log::warn; +use log::{debug, warn}; use nostr::Event; use rocket::fs::NamedFile; use rocket::http::{ContentType, Header, Status}; @@ -365,6 +365,7 @@ pub async fn void_cat_redirect(id: &str, settings: &State) -> Option {}", id, f.display()); if let Ok(f) = NamedFile::open(f).await { Some(f) } else {