Comprehensive review fixes: security, performance, code quality, and UI polish
Some checks failed
Validate / Hassfest (push) Has been cancelled
Some checks failed
Validate / Hassfest (push) Has been cancelled
Backend: Fix CORS wildcard+credentials, add secret key warning, remove raw API keys from sync endpoint, fix N+1 queries in watcher/sync, fix AttributeError on event_types, delete dead scheduled.py/templates.py, add limit cap on history, re-validate server on URL/key update, apply tracking/template config IDs in update_target. HA Integration: Replace datetime.now() with dt_util.now(), fix notification queue to only remove successfully sent items, use album UUID for entity unique IDs, add shared links dirty flag and users cache hourly refresh, deduplicate _is_quiet_hours, add HTTP timeouts, cache albums in config flow, change iot_class to local_polling. Frontend: Make i18n reactive via $state (remove window.location.reload), add Modal transitions/a11y/Escape key, create ConfirmModal replacing all confirm() calls, add error handling to all pages, replace Unicode nav icons with MDI SVGs, add card hover effects, dashboard stat icons, global focus-visible styles, form slide transitions, mobile responsive bottom nav, fix password error color, add ~20 i18n keys (EN/RU). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -166,16 +166,28 @@ async def _check_album(
|
||||
)
|
||||
session.add(event_log)
|
||||
|
||||
# Send notifications to each target, filtered by its tracking config
|
||||
for target_id in target_ids:
|
||||
target = await session.get(NotificationTarget, target_id)
|
||||
if not target:
|
||||
continue
|
||||
# Batch-load targets, tracking configs, and template configs
|
||||
targets_result = await session.exec(
|
||||
select(NotificationTarget).where(NotificationTarget.id.in_(target_ids))
|
||||
)
|
||||
targets = targets_result.all()
|
||||
|
||||
# Check target's tracking config for event filtering
|
||||
tracking_config = None
|
||||
if target.tracking_config_id:
|
||||
tracking_config = await session.get(TrackingConfig, target.tracking_config_id)
|
||||
tc_ids = {t.tracking_config_id for t in targets if t.tracking_config_id}
|
||||
tmpl_ids = {t.template_config_id for t in targets if t.template_config_id}
|
||||
|
||||
tracking_configs_map: dict[int, TrackingConfig] = {}
|
||||
if tc_ids:
|
||||
tc_result = await session.exec(select(TrackingConfig).where(TrackingConfig.id.in_(tc_ids)))
|
||||
tracking_configs_map = {tc.id: tc for tc in tc_result.all()}
|
||||
|
||||
template_configs_map: dict[int, TemplateConfig] = {}
|
||||
if tmpl_ids:
|
||||
tmpl_result = await session.exec(select(TemplateConfig).where(TemplateConfig.id.in_(tmpl_ids)))
|
||||
template_configs_map = {tc.id: tc for tc in tmpl_result.all()}
|
||||
|
||||
# Send notifications to each target, filtered by its tracking config
|
||||
for target in targets:
|
||||
tracking_config = tracking_configs_map.get(target.tracking_config_id) if target.tracking_config_id else None
|
||||
|
||||
if tracking_config:
|
||||
# Filter by event type
|
||||
@@ -193,16 +205,13 @@ async def _check_album(
|
||||
if not should_notify:
|
||||
continue
|
||||
|
||||
# Get target's template config
|
||||
template_config = None
|
||||
if target.template_config_id:
|
||||
template_config = await session.get(TemplateConfig, target.template_config_id)
|
||||
template_config = template_configs_map.get(target.template_config_id) if target.template_config_id else None
|
||||
|
||||
try:
|
||||
use_ai = target.config.get("ai_captions", False)
|
||||
await send_notification(target, event_data, template_config, use_ai_caption=use_ai)
|
||||
except Exception:
|
||||
_LOGGER.exception("Failed to send notification to target %d", target_id)
|
||||
_LOGGER.exception("Failed to send notification to target %d", target.id)
|
||||
|
||||
return {
|
||||
"album_id": album_id,
|
||||
|
||||
Reference in New Issue
Block a user