fix: comprehensive API/UI review — 26 bug fixes and improvements
Backend: - Scheduler lifecycle sync: create/update/delete tracker now syncs APScheduler jobs - Test-periodic/test-memory endpoints render actual Jinja2 templates with sample data - Cascade cleanup on tracker delete (TrackerState removed, EventLog nullified) - Fix user_id=0 FK violation for system-owned TemplateConfig (removed FK constraint) - Fix API key leak: only attach x-api-key header for internal provider URLs - Validate config ownership in tracker_targets create/update - Fix _response() double-emit of created_at in template/tracking configs - Add per-target-link test endpoints (test, test-periodic, test-memory) Frontend: - Fix orphaned provider on test exception in providers/new - Add submitting guard + disabled state to targets save button - Move test buttons from tracker card to per-target-link rows - Fix Svelte 5 async $state reactivity (spread reassignment for all Record mutations) - i18n for dashboard timeAgo and event type badges (EN + RU) - Add required attribute to chat select dropdown in targets - Fix font CSS vars to prioritize imported DM Sans / JetBrains Mono - Standardize empty states with centered icon + text across all 6 list pages - Add stagger-children animation class to all list containers - Fix slide transition duration consistency (200ms everywhere) - Standardize border-radius to rounded-md across all form inputs - Fix providers/new page structure (h2 + mb-8 spacing) - Fix tracker card action row overflow (flex-wrap justify-end) - JinjaEditor dark mode reactivity (recreate editor on theme change) - Add aria-labels to mobile nav items - Make ConfirmModal confirm button label/icon configurable - Remove double error reporting on providers page - Add telegram bot edit functionality (name editing via PUT) - i18n for External Domain label on provider forms Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -60,6 +60,16 @@ _SAMPLE_CONTEXT = {
|
||||
"collection_id": "b2eeeaa4-bba0-477a-a06f-5cb9e21818e8",
|
||||
"collection_name": "Family Photos",
|
||||
"collection_url": "https://immich.example.com/share/abc123",
|
||||
"event_type": "assets_added",
|
||||
"timestamp": "2026-03-19T10:30:00+00:00",
|
||||
"service_name": "Immich",
|
||||
"service_type": "immich",
|
||||
# Immich aliases (always present alongside collection_*)
|
||||
"album_name": "Family Photos",
|
||||
"album_id": "b2eeeaa4-bba0-477a-a06f-5cb9e21818e8",
|
||||
"album_url": "https://immich.example.com/share/abc123",
|
||||
"old_album_name": "Old Album",
|
||||
"new_album_name": "New Album",
|
||||
"change_type": "assets_added",
|
||||
"added_count": 3,
|
||||
"removed_count": 1,
|
||||
@@ -118,31 +128,109 @@ async def list_configs(
|
||||
|
||||
|
||||
@router.get("/variables")
|
||||
async def get_template_variables(provider_type: str | None = None):
|
||||
"""Get the variable reference for all template slots."""
|
||||
from .template_vars import router as _ # noqa: ensure registered
|
||||
from notify_bridge_core.providers.base import ServiceProviderType
|
||||
from notify_bridge_core.templates.variables import registry
|
||||
async def get_template_variables():
|
||||
"""Get template variable reference grouped by slot.
|
||||
|
||||
if provider_type:
|
||||
try:
|
||||
pt = ServiceProviderType(provider_type)
|
||||
except ValueError:
|
||||
return {"error": f"Unknown provider type: {provider_type}"}
|
||||
variables = registry.get_variables(pt)
|
||||
else:
|
||||
variables = registry.get_base_variables()
|
||||
Returns a dict keyed by template slot name, each containing:
|
||||
- description: what the slot is for
|
||||
- variables: dict of variable_name -> description
|
||||
- asset_fields: dict of field_name -> description (for slots with assets)
|
||||
- album_fields: dict of field_name -> description (for slots with albums)
|
||||
"""
|
||||
# Core event variables available in all event templates
|
||||
event_vars = {
|
||||
"collection_id": "Collection ID (UUID)",
|
||||
"collection_name": "Collection name",
|
||||
"collection_url": "Public share URL (empty if not shared)",
|
||||
"added_count": "Number of assets added",
|
||||
"removed_count": "Number of assets removed",
|
||||
"people": "Detected people names (list, use {{ people | join(', ') }})",
|
||||
"shared": "Whether collection is shared (boolean)",
|
||||
"target_type": "Target type: 'telegram' or 'webhook'",
|
||||
"has_videos": "Whether added assets contain videos (boolean)",
|
||||
"has_photos": "Whether added assets contain photos (boolean)",
|
||||
# Immich aliases
|
||||
"album_name": "Alias for collection_name",
|
||||
"album_id": "Alias for collection_id",
|
||||
"album_url": "Alias for collection_url",
|
||||
}
|
||||
rename_vars = {
|
||||
**event_vars,
|
||||
"old_name": "Previous name (rename events)",
|
||||
"new_name": "New name (rename events)",
|
||||
}
|
||||
sharing_vars = {
|
||||
**event_vars,
|
||||
"old_shared": "Was shared before change (boolean)",
|
||||
"new_shared": "Is shared after change (boolean)",
|
||||
}
|
||||
asset_fields = {
|
||||
"id": "Asset ID (UUID)",
|
||||
"filename": "Original filename",
|
||||
"type": "IMAGE or VIDEO",
|
||||
"created_at": "Creation date/time (ISO 8601)",
|
||||
"owner": "Owner display name",
|
||||
"description": "User or EXIF description",
|
||||
"people": "People detected in this asset (list)",
|
||||
"is_favorite": "Whether asset is favorited (boolean)",
|
||||
"rating": "Star rating (1-5 or null)",
|
||||
"city": "City name",
|
||||
"state": "State/region name",
|
||||
"country": "Country name",
|
||||
"url": "Public viewer URL (if shared)",
|
||||
"download_url": "Direct download URL (if shared)",
|
||||
"photo_url": "Preview image URL (images only, if shared)",
|
||||
"playback_url": "Video playback URL (videos only, if shared)",
|
||||
}
|
||||
album_fields = {
|
||||
"name": "Collection/album name",
|
||||
"url": "Share URL",
|
||||
"asset_count": "Total assets in collection",
|
||||
"shared": "Whether collection is shared",
|
||||
}
|
||||
scheduled_vars = {
|
||||
"date": "Current date string",
|
||||
"target_type": "Target type: 'telegram' or 'webhook'",
|
||||
}
|
||||
|
||||
return [
|
||||
{
|
||||
"name": v.name,
|
||||
"type": v.type,
|
||||
"description": v.description,
|
||||
"example": v.example,
|
||||
"provider_type": v.provider_type.value if v.provider_type else None,
|
||||
}
|
||||
for v in variables
|
||||
]
|
||||
return {
|
||||
"message_assets_added": {
|
||||
"description": "Notification when new assets are added to a collection",
|
||||
"variables": {**event_vars, "added_assets": "List of asset dicts (use {% for asset in added_assets %})"},
|
||||
"asset_fields": asset_fields,
|
||||
},
|
||||
"message_assets_removed": {
|
||||
"description": "Notification when assets are removed from a collection",
|
||||
"variables": {**event_vars, "removed_assets": "List of removed asset IDs (strings)"},
|
||||
},
|
||||
"message_collection_renamed": {
|
||||
"description": "Notification when a collection is renamed",
|
||||
"variables": rename_vars,
|
||||
},
|
||||
"message_collection_deleted": {
|
||||
"description": "Notification when a collection is deleted",
|
||||
"variables": event_vars,
|
||||
},
|
||||
"message_sharing_changed": {
|
||||
"description": "Notification when sharing status changes",
|
||||
"variables": sharing_vars,
|
||||
},
|
||||
"periodic_summary_message": {
|
||||
"description": "Periodic summary of all tracked collections",
|
||||
"variables": {**scheduled_vars, "collections": "List of collection dicts (use {% for album in collections %})"},
|
||||
"album_fields": album_fields,
|
||||
},
|
||||
"scheduled_assets_message": {
|
||||
"description": "Scheduled asset delivery (daily photo picks)",
|
||||
"variables": {**scheduled_vars, "assets": "List of asset dicts (use {% for asset in assets %})"},
|
||||
"asset_fields": asset_fields,
|
||||
},
|
||||
"memory_mode_message": {
|
||||
"description": "\"On This Day\" memories from previous years",
|
||||
"variables": {**scheduled_vars, "assets": "List of asset dicts (use {% for asset in assets %})"},
|
||||
"asset_fields": asset_fields,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@router.post("", status_code=status.HTTP_201_CREATED)
|
||||
@@ -259,8 +347,9 @@ async def preview_raw(
|
||||
|
||||
|
||||
def _response(c: TemplateConfig) -> dict:
|
||||
return {k: getattr(c, k) for k in TemplateConfig.model_fields if k != "user_id"} | {
|
||||
"created_at": c.created_at.isoformat()
|
||||
return {k: getattr(c, k) for k in TemplateConfig.model_fields if k not in ("user_id", "created_at")} | {
|
||||
"user_id": c.user_id,
|
||||
"created_at": c.created_at.isoformat(),
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user