Files
ericmey-comfyui-immich/__init__.py
T
560b07d232 feat: read-only connection status and test from the node menu; config in ComfyUI's user dir (#11)
* feat: read-only connection status and test from the node menu; config in ComfyUI's user dir

Implements the shared status contract v1:

- GET /immich/status: the configured URL, whether a key is set (a boolean,
  never the key or anything derived from it), where each came from, and the
  config file paths.
- POST /immich/test: one GET /api/users/me against the *saved* URL with the
  saved key. Any query string or body gets 400 (no URL or key is ever taken
  from the caller). Rate-limited to one call per 5 s (429). Returns only an
  HTTP status and an error class, never the remote body.
- There is no write path: ComfyUI has no authentication by default, so a
  write route would let anyone who can reach it replace the key or redirect
  uploads.
- The node's right-click menu gets "Immich: connection status" and
  "Immich: test connection" (web/immich_status.js). The menu adds no widgets,
  so nothing is serialized into workflows.
- Config precedence: environment, then ComfyUI/user/comfyui-immich.env
  (survives reinstalling the node), then the node folder's .env.

Tests: test_status.py covers no key material in any response (with a mutation
check on the detector), input refused with zero outbound calls, the single
call going to the saved URL, the rate limit, error classes and precedence.
test_routes_http.py serves the real aiohttp routes (skipped without aiohttp)
and fails if the adapter ignores its input.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix: refuse a /immich/test body without buffering it

The adapter read the whole request body before refusing input, so a caller
could make the route buffer a large upload. A declared Content-Length is now
refused unread, and a chunked or unknown-length body after at most one byte.

Raw-socket tests declare a 100 MB body (or a never-terminated chunked body)
and expect an immediate 400 with no outbound call. The previous adapter
fails both by waiting for the body.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Shiori <shiori@harem.world>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 15:47:31 -04:00

22 lines
621 B
Python

try:
from .immich_nodes.routes import register as _register_routes
from .immich_nodes.save_to_immich import SaveToImmich
except ImportError:
from immich_nodes.routes import register as _register_routes
from immich_nodes.save_to_immich import SaveToImmich
# Read-only status routes (GET /immich/status, POST /immich/test); no-op outside ComfyUI.
_register_routes()
WEB_DIRECTORY = "./web"
NODE_CLASS_MAPPINGS = {
"SaveToImmich": SaveToImmich,
}
NODE_DISPLAY_NAME_MAPPINGS = {
"SaveToImmich": "Save to Immich",
}
__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS", "WEB_DIRECTORY"]