Release v0.1.9: enforce Photos API boundary and finalize Server migration
This commit is contained in:
@@ -109,7 +109,18 @@ class PhotoSources:
|
||||
raise FlowError(E.NOT_FOUND, "Photo source not found", 404)
|
||||
return PhotoSourceInput.model_validate_json(row["payload"])
|
||||
|
||||
@staticmethod
|
||||
def require_api_source(source):
|
||||
# Block persisted legacy sources as well as new requests, before any disk read.
|
||||
if source.kind == "local":
|
||||
raise FlowError(
|
||||
E.FORBIDDEN,
|
||||
"Filesystem photo sources are disabled; use the Synology Photos API",
|
||||
403,
|
||||
)
|
||||
|
||||
def save(self, source_id, source):
|
||||
self.require_api_source(source)
|
||||
if source.minimum_brightness > source.maximum_brightness:
|
||||
raise FlowError(E.INVALID_REQUEST, "Brightness range is reversed")
|
||||
if source.kind not in ("local", "synology-photos") and (
|
||||
@@ -284,6 +295,7 @@ class PhotoSources:
|
||||
|
||||
def catalog(self, source_id, refresh=False, *, target_size=(1200, 1600)):
|
||||
source = self.get(source_id)
|
||||
self.require_api_source(source)
|
||||
if not source.enabled:
|
||||
raise FlowError(E.CONFLICT, "Photo source is disabled", 409)
|
||||
session_identity = (
|
||||
|
||||
Reference in New Issue
Block a user