feat: accept void-cat uuid

This commit is contained in:
kieran 2025-02-04 13:09:02 +00:00
parent 5530f39779
commit 314d0c68af
No known key found for this signature in database
GPG Key ID: DE71CEB3925BE941

View File

@ -437,10 +437,15 @@ pub async fn void_cat_redirect(id: &str, settings: &State<Settings>) -> Option<N
id id
}; };
if let Some(base) = &settings.void_cat_files { if let Some(base) = &settings.void_cat_files {
let uuid = let uuid = if let Ok(b58) = nostr::bitcoin::base58::decode(id) {
uuid::Uuid::from_slice_le(nostr::bitcoin::base58::decode(id).unwrap().as_slice()) uuid::Uuid::from_slice_le(b58.as_slice())
.unwrap(); } else {
let f = base.join(VoidFile::map_to_path(&uuid)); uuid::Uuid::parse_str(id)
};
if uuid.is_err() {
return None;
}
let f = base.join(VoidFile::map_to_path(&uuid.unwrap()));
debug!("Legacy file map: {} => {}", id, f.display()); debug!("Legacy file map: {} => {}", id, f.display());
if let Ok(f) = NamedFile::open(f).await { if let Ok(f) = NamedFile::open(f).await {
Some(f) Some(f)