feat: smart video size warnings + Jinja2 template autocomplete

Video size warnings:
- Add file_size field to ImmichAssetInfo from exifInfo.fileSizeInByte
- Expose per-target max_video_size (50 MB for Telegram, none for others)
- Compute has_oversized_videos and per-asset oversized flag in template context
- Default templates show warning only when videos actually exceed the limit
- Templates no longer hardcode Telegram-specific logic

Template autocomplete:
- New jinja-autocomplete.ts engine with contextual completions
- Top-level variables ({{ }}), asset/album fields (dot access in loops),
  Jinja2 filters (|), block tags ({% %}), and loop.* special vars
- JinjaEditor accepts optional variables prop via CodeMirror Compartment
- Wired into template-configs and command-template-configs pages

Also: fix template emoji (📷📎) and sync sample_context with new vars.
This commit is contained in:
2026-03-23 15:03:35 +03:00
parent 1ac6a17f6f
commit 39bac828fd
14 changed files with 365 additions and 11 deletions
@@ -1,4 +1,12 @@
"""Sample template context for previews and test notifications."""
"""Sample template context for previews and test notifications.
IMPORTANT: Keep sample assets and context in sync with:
- ``notify_bridge_core.templates.context.build_template_context`` (runtime variables)
- ``notify_bridge_server.api.template_configs`` (variable docs)
- ``notify_bridge_core.templates.validator`` (runtime_vars whitelist)
When adding new template variables, update all four locations.
"""
# Sample asset matching what build_asset_detail() actually returns
_SAMPLE_ASSET = {
@@ -21,6 +29,8 @@ _SAMPLE_ASSET = {
"public_url": "https://immich.example.com/share/abc123/photos/a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"download_url": "https://immich.example.com/api/assets/abc123/original",
"photo_url": "https://immich.example.com/api/assets/abc123/thumbnail",
"file_size": 3_500_000, # 3.5 MB
"oversized": False,
}
_SAMPLE_VIDEO_ASSET = {
@@ -33,6 +43,8 @@ _SAMPLE_VIDEO_ASSET = {
"photo_url": None,
"public_url": "https://immich.example.com/share/abc123/photos/d4e5f6a7-b8c9-0123-defg-456789abcdef",
"playback_url": "https://immich.example.com/api/assets/def456/video",
"file_size": 75_000_000, # 75 MB — exceeds Telegram's 50 MB limit
"oversized": True,
}
_SAMPLE_COLLECTION = {
@@ -68,6 +80,9 @@ _SAMPLE_CONTEXT = {
"target_type": "telegram",
"has_videos": True,
"has_photos": True,
"has_oversized_videos": True,
"max_video_size": 50 * 1024 * 1024, # 50 MB in bytes
"max_video_size_mb": 50,
# Rename fields (always present, empty for non-rename events)
"old_name": "Old Album",
"new_name": "New Album",