Add starred cloud photos and opt-in seven-day random upload retention
This commit is contained in:
@@ -80,6 +80,7 @@ Content = Annotated[
|
||||
|
||||
|
||||
class Options(StrictModel):
|
||||
cleanup_unstarred: bool = False
|
||||
duration: int = Field(default=0, ge=0, le=604800)
|
||||
restore_previous: bool = False
|
||||
priority: int = Field(default=50, ge=0, le=100)
|
||||
@@ -102,6 +103,15 @@ class DisplayRequest(StrictModel):
|
||||
options: Options = Field(default_factory=Options)
|
||||
source: Source = Field(default_factory=Source)
|
||||
|
||||
@model_validator(mode="after")
|
||||
def retention_source(self):
|
||||
if self.options.cleanup_unstarred and not (
|
||||
isinstance(self.content, PhotoSourceContent)
|
||||
and self.content.item_id is None
|
||||
):
|
||||
raise ValueError("Retention requires random photo-source content")
|
||||
return self
|
||||
|
||||
|
||||
class Accepted(BaseModel):
|
||||
operation_id: str
|
||||
@@ -203,6 +213,8 @@ class Device(BaseModel):
|
||||
|
||||
|
||||
class GalleryImage(BaseModel):
|
||||
starred: bool = False
|
||||
expires_at: str | None = None
|
||||
width: int | None = None
|
||||
height: int | None = None
|
||||
size_bytes: int | None = None
|
||||
@@ -226,6 +238,7 @@ class RestoreContent(StrictModel):
|
||||
|
||||
|
||||
class JobInput(StrictModel):
|
||||
cleanup_unstarred: bool = False
|
||||
enabled: bool = True
|
||||
device_id: str = "living-room"
|
||||
name: str = Field(min_length=1, max_length=120)
|
||||
@@ -237,6 +250,10 @@ class JobInput(StrictModel):
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_options(self):
|
||||
if self.cleanup_unstarred and not (
|
||||
isinstance(self.source, PhotoSourceContent) and self.source.item_id is None
|
||||
):
|
||||
raise ValueError("Retention requires a random photo-source task")
|
||||
Options(
|
||||
duration=self.display_duration,
|
||||
restore_previous=self.restore_previous,
|
||||
@@ -418,3 +435,7 @@ class WidgetState(StrictModel):
|
||||
current: Widget | None = None
|
||||
current_verified: bool = False
|
||||
writable: Literal[False] = False
|
||||
|
||||
|
||||
class ImageStar(StrictModel):
|
||||
starred: bool
|
||||
|
||||
Reference in New Issue
Block a user