Use PhotoSize enum in file requests #29
@@ -103,7 +103,8 @@ pub struct PhotosResponse {
|
||||
#[derive(Deserialize)]
|
||||
pub struct FilesRequest {
|
||||
pub path: String,
|
||||
pub tag_ids: Option<String>, // comma separated numbers
|
||||
// comma separated numbers
|
||||
pub tag_ids: Option<String>,
|
||||
pub tag_filter_mode: Option<FilterMode>,
|
||||
pub recursive: Option<bool>,
|
||||
}
|
||||
@@ -114,10 +115,17 @@ pub enum FilterMode {
|
||||
All,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Deserialize, PartialEq, Debug)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum PhotoSize {
|
||||
Full,
|
||||
Thumb,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct ThumbnailRequest {
|
||||
pub path: String,
|
||||
pub size: Option<String>,
|
||||
pub size: Option<PhotoSize>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
|
||||
@@ -80,7 +80,8 @@ async fn get_image(
|
||||
app_state: Data<AppState>,
|
||||
) -> impl Responder {
|
||||
if let Some(path) = is_valid_full_path(&app_state.base_path, &req.path, false) {
|
||||
if req.size.is_some() {
|
||||
let image_size = req.size.unwrap_or(PhotoSize::Full);
|
||||
if image_size == PhotoSize::Thumb {
|
||||
let relative_path = path
|
||||
.strip_prefix(&app_state.base_path)
|
||||
.expect("Error stripping base path prefix from thumbnail");
|
||||
|
||||
Reference in New Issue
Block a user