fix: head void_cat_redirect

This commit is contained in:
kieran 2025-01-30 22:25:56 +00:00
parent 4f40efa99c
commit 5530f39779
No known key found for this signature in database
GPG Key ID: DE71CEB3925BE941
2 changed files with 22 additions and 1 deletions

View File

@ -73,7 +73,7 @@ async fn main() -> Result<(), Error> {
.attach(Shield::new()) // disable
.mount(
"/",
routes![root, get_blob, head_blob, routes::void_cat_redirect],
routes![root, get_blob, head_blob, routes::void_cat_redirect, routes::void_cat_redirect_head],
)
.mount("/admin", routes::admin_routes());

View File

@ -451,3 +451,24 @@ pub async fn void_cat_redirect(id: &str, settings: &State<Settings>) -> Option<N
None
}
}
#[rocket::head("/d/<id>")]
pub async fn void_cat_redirect_head(id: &str) -> VoidCatFile {
let id = if id.contains(".") {
id.split('.').next().unwrap()
} else {
id
};
let uuid =
uuid::Uuid::from_slice_le(nostr::bitcoin::base58::decode(id).unwrap().as_slice()).unwrap();
VoidCatFile {
status: Status::Ok,
uuid: Header::new("X-UUID", uuid.to_string()),
}
}
#[derive(Responder)]
pub struct VoidCatFile {
pub status: Status,
pub uuid: Header<'static>,
}