feat: UX & notification improvements — icons, events, chat names, link validation, templates
- Show entity icons on all cards with fallback defaults (providers, trackers, targets, bots)
- Enrich EventLog with provider_name, tracker_name, assets_count; add DB migration
- Dashboard events: filtering (type, provider, search), sorting, pagination, dynamic page size
- Friendly chat names on telegram target cards (resolve from TelegramChat table)
- Test message button on bot chat items with locale-aware messages
- Album public link validation on tracker save with auto-create dialog
- Support albums without public links: conditional <a href> in templates
- Fetch shared links during poll, enrich events with public_url/protected_url
- Per-asset public_url in template context ({share_url}/photos/{asset_id})
- Common date/location detection: common_date + common_location context vars
- Dual date formats: date_format (datetime) + date_only_format (date only)
- Template clone button, HTML link rendering in template preview
- Fix Telegram asset download 401: pass x-api-key headers through client
- Fix provider external_url matching for API key scoping
- Fix event timestamp timezone (append Z suffix for UTC)
- Localize event filter controls, test messages (EN/RU)
- Template variable UI helpers updated with all new fields
- CLAUDE.md: template system sync rules documentation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
# Phase 4: Friendly Chat Names + Test Message for Bots
|
||||
|
||||
**Status:** ⬜ Not Started
|
||||
**Parent plan:** [PLAN.md](./PLAN.md)
|
||||
**Domain:** fullstack
|
||||
|
||||
## Objective
|
||||
Two Telegram UX improvements: (a) show friendly chat names instead of raw IDs on target cards, (b) add a "Send Test Message" button to each chat item on the bots page.
|
||||
|
||||
## Tasks
|
||||
|
||||
### 4a: Friendly Chat Names on Target Cards
|
||||
- [ ] Task 1: Update GET /api/targets in targets.py to resolve chat_id → friendly name by looking up TelegramChat table (match on bot token's bot_id + chat_id)
|
||||
- [ ] Task 2: Include `chat_name` field in target API response alongside chat_id
|
||||
- [ ] Task 3: Update target cards in targets/+page.svelte to display "Chat Name (chat_id)" instead of raw chat_id
|
||||
|
||||
### 4b: Test Message Button for Bot Chats
|
||||
- [ ] Task 4: Add POST /api/telegram-bots/{bot_id}/chats/{chat_id}/test endpoint in telegram_bots.py that sends a simple test message via the bot
|
||||
- [ ] Task 5: Add "Send Test" button to each chat item in telegram-bots/+page.svelte with loading/success/error feedback
|
||||
- [ ] Task 6: Handle edge cases (bot can't reach chat, chat deleted, etc.) with proper error messages
|
||||
|
||||
## Files to Modify/Create
|
||||
- `packages/server/src/notify_bridge_server/api/targets.py` — resolve chat names
|
||||
- `packages/server/src/notify_bridge_server/api/telegram_bots.py` — test message endpoint
|
||||
- `frontend/src/routes/targets/+page.svelte` — display friendly names
|
||||
- `frontend/src/routes/telegram-bots/+page.svelte` — test message button
|
||||
|
||||
## Acceptance Criteria
|
||||
- Target cards show "Chat Title (chat_id)" for telegram targets where chat name is known
|
||||
- Falls back to just chat_id when no matching TelegramChat record exists
|
||||
- Test message button sends a simple "Test message from Notify Bridge" to the chat
|
||||
- Button shows loading state, then success/error feedback
|
||||
- Error messages are user-friendly (not raw API errors)
|
||||
|
||||
## Notes
|
||||
- TelegramChat stores: chat_id (string), title, chat_type, username, bot_id (FK)
|
||||
- NotificationTarget.config stores: bot_token, chat_id
|
||||
- To resolve: need to find TelegramBot by token → get bot_id → lookup TelegramChat by (bot_id, chat_id)
|
||||
- For test message: use TelegramClient directly with bot token from TelegramBot record
|
||||
- The test endpoint on targets already exists (POST /api/targets/{id}/test) — this is a NEW endpoint specifically for bot chat items
|
||||
|
||||
## Review Checklist
|
||||
- [ ] All tasks completed
|
||||
- [ ] Code follows project conventions
|
||||
- [ ] No unintended side effects
|
||||
- [ ] Build passes
|
||||
- [ ] Tests pass (new + existing)
|
||||
|
||||
## Handoff to Next Phase
|
||||
<!-- Filled in after completion -->
|
||||
Reference in New Issue
Block a user