pinakes-server: relativize media paths against configured root directories
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I9f113e6402030c46ad97f636985b5d6c6a6a6964
This commit is contained in:
parent
5077e9f117
commit
3aa1503441
11 changed files with 208 additions and 40 deletions
|
|
@ -506,6 +506,7 @@ pub async fn access_shared(
|
|||
let _ = state.storage.record_share_activity(&activity).await;
|
||||
|
||||
// Return the shared content
|
||||
let roots = state.config.read().await.directories.roots.clone();
|
||||
match &share.target {
|
||||
ShareTarget::Media { media_id } => {
|
||||
let item = state
|
||||
|
|
@ -514,8 +515,8 @@ pub async fn access_shared(
|
|||
.await
|
||||
.map_err(|e| ApiError::not_found(format!("Media not found: {e}")))?;
|
||||
|
||||
Ok(Json(SharedContentResponse::Single(MediaResponse::from(
|
||||
item,
|
||||
Ok(Json(SharedContentResponse::Single(MediaResponse::new(
|
||||
item, &roots,
|
||||
))))
|
||||
},
|
||||
ShareTarget::Collection { collection_id } => {
|
||||
|
|
@ -527,8 +528,10 @@ pub async fn access_shared(
|
|||
ApiError::not_found(format!("Collection not found: {e}"))
|
||||
})?;
|
||||
|
||||
let items: Vec<MediaResponse> =
|
||||
members.into_iter().map(MediaResponse::from).collect();
|
||||
let items: Vec<MediaResponse> = members
|
||||
.into_iter()
|
||||
.map(|item| MediaResponse::new(item, &roots))
|
||||
.collect();
|
||||
|
||||
Ok(Json(SharedContentResponse::Multiple { items }))
|
||||
},
|
||||
|
|
@ -553,8 +556,11 @@ pub async fn access_shared(
|
|||
.await
|
||||
.map_err(|e| ApiError::internal(format!("Search failed: {e}")))?;
|
||||
|
||||
let items: Vec<MediaResponse> =
|
||||
results.items.into_iter().map(MediaResponse::from).collect();
|
||||
let items: Vec<MediaResponse> = results
|
||||
.items
|
||||
.into_iter()
|
||||
.map(|item| MediaResponse::new(item, &roots))
|
||||
.collect();
|
||||
|
||||
Ok(Json(SharedContentResponse::Multiple { items }))
|
||||
},
|
||||
|
|
@ -585,8 +591,11 @@ pub async fn access_shared(
|
|||
.await
|
||||
.map_err(|e| ApiError::internal(format!("Search failed: {e}")))?;
|
||||
|
||||
let items: Vec<MediaResponse> =
|
||||
results.items.into_iter().map(MediaResponse::from).collect();
|
||||
let items: Vec<MediaResponse> = results
|
||||
.items
|
||||
.into_iter()
|
||||
.map(|item| MediaResponse::new(item, &roots))
|
||||
.collect();
|
||||
|
||||
Ok(Json(SharedContentResponse::Multiple { items }))
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue