diff options
author | metamuffin <metamuffin@disroot.org> | 2024-01-23 04:30:27 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-01-23 04:30:27 +0100 |
commit | 31675068c5ef1af1c4ae50693ace7ab1b6890393 (patch) | |
tree | 28dd729c42adaa1ac7ba73a8d3ff9bc5ded0db39 /server/src/routes | |
parent | e5712e82b369019457cf738a70ae97c67388cbc4 (diff) | |
download | jellything-31675068c5ef1af1c4ae50693ace7ab1b6890393.tar jellything-31675068c5ef1af1c4ae50693ace7ab1b6890393.tar.bz2 jellything-31675068c5ef1af1c4ae50693ace7ab1b6890393.tar.zst |
assets depended fallback images
Diffstat (limited to 'server/src/routes')
-rw-r--r-- | server/src/routes/ui/assets.rs | 13 | ||||
-rw-r--r-- | server/src/routes/ui/mod.rs | 1 |
2 files changed, 5 insertions, 9 deletions
diff --git a/server/src/routes/ui/assets.rs b/server/src/routes/ui/assets.rs index ebd9453..d5d2839 100644 --- a/server/src/routes/ui/assets.rs +++ b/server/src/routes/ui/assets.rs @@ -19,7 +19,6 @@ pub use jellycommon::AssetRole; use jellycommon::{AssetLocation, LocalTrack, PeopleGroup, SourceTrackKind, TrackSource}; use log::info; use rocket::{get, http::ContentType, State}; -use std::{path::PathBuf, str::FromStr}; use tokio::fs::File; #[get("/n/<id>/asset?<role>&<width>")] @@ -51,7 +50,7 @@ pub async fn r_item_assets( } }; let asset = asset.unwrap_or(AssetLocation::Assets( - PathBuf::from_str("fallback.avif").unwrap(), + format!("fallback-{:?}.avif", node.public.kind.unwrap_or_default()).into(), )); Ok(asset_with_res(asset, width).await?) } @@ -78,13 +77,9 @@ pub async fn r_person_asset( .get(index) .ok_or(anyhow!("person does not exist"))?; - let asset = app - .person - .asset - .as_ref() - .ok_or(anyhow!("no asset"))? - .to_owned(); - + let asset = app.person.asset.to_owned().unwrap_or(AssetLocation::Assets( + format!("fallback-Person.avif").into(), + )); Ok(asset_with_res(asset, width).await?) } diff --git a/server/src/routes/ui/mod.rs b/server/src/routes/ui/mod.rs index af8cf10..3a006a9 100644 --- a/server/src/routes/ui/mod.rs +++ b/server/src/routes/ui/mod.rs @@ -68,6 +68,7 @@ pub struct CacheControlFile(File, String); impl CacheControlFile { pub async fn new(f: File) -> Self { let meta = f.metadata().await.unwrap(); + // TODO ETag should be cache path (or something like that) so federation clients can dedup assets let modified = meta.mtime(); let mut h = DefaultHasher::new(); modified.hash(&mut h); |