feat: manage saved thumbnail plans and select plans for tasks
This commit is contained in:
@@ -107,6 +107,8 @@ Content = Annotated[
|
||||
|
||||
|
||||
class Options(StrictModel):
|
||||
generate_thumbnail: bool = True
|
||||
thumbnail_plan_id: str | None = Field(default=None, pattern=r"^[a-f0-9]{32}$")
|
||||
cleanup_unstarred: bool = False
|
||||
duration: int = Field(default=0, ge=0, le=604800)
|
||||
restore_previous: bool = False
|
||||
@@ -281,6 +283,8 @@ class RestoreContent(StrictModel):
|
||||
|
||||
|
||||
class JobInput(StrictModel):
|
||||
generate_thumbnail: bool = False
|
||||
thumbnail_plan_id: str | None = Field(default=None, pattern=r"^[a-f0-9]{32}$")
|
||||
cleanup_unstarred: bool = False
|
||||
enabled: bool = True
|
||||
device_id: str = "living-room"
|
||||
@@ -293,6 +297,15 @@ class JobInput(StrictModel):
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_options(self):
|
||||
if self.generate_thumbnail and (
|
||||
not self.thumbnail_plan_id
|
||||
or not isinstance(self.source, PhotoSourceContent)
|
||||
):
|
||||
raise ValueError(
|
||||
"Thumbnail generation requires a photo source and one saved plan"
|
||||
)
|
||||
if not self.generate_thumbnail and self.thumbnail_plan_id:
|
||||
raise ValueError("Enable thumbnail generation before selecting a plan")
|
||||
if self.cleanup_unstarred and not (
|
||||
isinstance(self.source, PhotoSourceContent) and self.source.item_id is None
|
||||
):
|
||||
|
||||
Reference in New Issue
Block a user