feat: implement desktop notifications with comprehensive filtering
Implemented Phase 10 (Desktop Notifications) with three stages: notify-rust integration, smart filtering, and production polish. Stage 1 - Base Implementation: - Add NotificationManager module (src/notifications.rs, 350+ lines) - Integrate notify-rust 4.11 with feature flag "notifications" - Implement NotificationsConfig in config.toml (enabled, only_mentions, show_preview) - Add notification_manager field to TdClient - Create configure_notifications() method for config integration - Hook into handle_new_message_update() to send notifications - Send notifications for messages outside current chat - Format notification body with sender name and message preview Stage 2 - Smart Filtering: - Sync muted chats from Telegram (sync_muted_chats method) - Filter muted chats from notifications automatically - Add MessageInfo::has_mention() to detect @username mentions - Implement only_mentions filter (notify only when mentioned) - Beautify media labels with emojis (📷 📹 🎤 🎨 📎 etc.) - Support 10+ media types in notification preview Stage 3 - Production Polish: - Add graceful error handling (no panics on notification failure) - Implement comprehensive logging (tracing::debug!/warn!) - Add timeout_ms configuration (0 = system default) - Add urgency configuration (low/normal/critical, Linux only) - Platform-specific #[cfg] for urgency support - Log all notification skip reasons at debug level Hotkey Change: - Move profile view from 'i' to Ctrl+i to avoid conflicts Technical Details: - Cross-platform support (macOS, Linux, Windows) - Feature flag for optional notifications support - Graceful fallback when notifications unavailable - LRU-friendly muted chats sync - Test coverage for all core notification logic - All 75 tests passing Files Changed: - NEW: src/notifications.rs - Complete NotificationManager - NEW: config.example.toml - Example configuration with notifications - Modified: Cargo.toml - Add notify-rust 4.11 dependency - Modified: src/config/mod.rs - Add NotificationsConfig struct - Modified: src/tdlib/types.rs - Add has_mention() method - Modified: src/tdlib/client.rs - Add notification integration - Modified: src/tdlib/update_handlers.rs - Hook notifications - Modified: src/config/keybindings.rs - Change profile to Ctrl+i - Modified: tests/* - Add notification config to tests Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
54
ROADMAP.md
54
ROADMAP.md
@@ -129,7 +129,7 @@
|
||||
- Индикатор черновика в списке чатов
|
||||
- Восстановление текста при возврате в чат
|
||||
- [x] Профиль пользователя/чата
|
||||
- `i` — открыть информацию о чате/собеседнике
|
||||
- `Ctrl+i` — открыть информацию о чате/собеседнике
|
||||
- Для личных чатов: имя, username, телефон, био
|
||||
- Для групп: название, описание, количество участников
|
||||
- [x] Копирование сообщений
|
||||
@@ -143,3 +143,55 @@
|
||||
- `~/.config/tele-tui/config.toml`
|
||||
- Настройки: цветовая схема, часовой пояс, хоткеи
|
||||
- Загрузка конфига при старте
|
||||
|
||||
## Фаза 10: Desktop уведомления [DONE - 83%]
|
||||
|
||||
### Стадия 1: Базовая реализация [DONE]
|
||||
- [x] NotificationManager модуль
|
||||
- notify-rust интеграция (версия 4.11)
|
||||
- Feature flag "notifications" в Cargo.toml
|
||||
- Базовая структура с настройками
|
||||
- [x] Конфигурация уведомлений
|
||||
- NotificationsConfig в config.toml
|
||||
- enabled: bool - вкл/выкл уведомлений
|
||||
- only_mentions: bool - только упоминания
|
||||
- show_preview: bool - показывать превью текста
|
||||
- [x] Интеграция с TdClient
|
||||
- Поле notification_manager в TdClient
|
||||
- Метод configure_notifications()
|
||||
- Обработка в handle_new_message_update()
|
||||
- [x] Базовая отправка уведомлений
|
||||
- Уведомления для сообщений не из текущего чата
|
||||
- Форматирование title (имя чата) и body (текст/медиа-заглушка)
|
||||
- Sender name из MessageInfo
|
||||
|
||||
### Стадия 2: Улучшения [IN PROGRESS]
|
||||
- [x] Синхронизация muted чатов
|
||||
- Загрузка списка muted чатов из Telegram
|
||||
- Вызов sync_muted_chats() при инициализации и обновлении (Ctrl+R)
|
||||
- Muted чаты автоматически фильтруются из уведомлений
|
||||
- [x] Фильтрация по упоминаниям
|
||||
- Метод MessageInfo::has_mention() проверяет TextEntityType::Mention и MentionName
|
||||
- NotificationManager применяет фильтр only_mentions из конфига
|
||||
- Работает для @username и inline mentions
|
||||
- [x] Поддержка типов медиа
|
||||
- Метод beautify_media_labels() заменяет текстовые заглушки на emoji
|
||||
- Поддержка: 📷 Фото, 🎥 Видео, 🎞️ GIF, 🎤 Голосовое, 🎨 Стикер
|
||||
- Также: 📎 Файл, 🎵 Аудио, 📹 Видеосообщение, 📍 Локация, 👤 Контакт, 📊 Опрос
|
||||
- [ ] Кастомизация звуков
|
||||
- Настройка звуков уведомлений в config.toml
|
||||
- Разные звуки для разных типов сообщений
|
||||
|
||||
### Стадия 3: Полировка [DONE]
|
||||
- [x] Обработка ошибок
|
||||
- Graceful fallback если уведомления недоступны (возвращает Ok без паники)
|
||||
- Логирование ошибок через tracing::warn!
|
||||
- Детальное логирование причин пропуска уведомлений (debug level)
|
||||
- [x] Дополнительные настройки
|
||||
- timeout_ms - продолжительность показа (0 = системное значение)
|
||||
- urgency - уровень важности: "low", "normal", "critical" (только Linux)
|
||||
- Красивые эмодзи для типов медиа
|
||||
- [ ] Опциональные улучшения (не критично)
|
||||
- Кросс-платформенное тестирование (требует ручного тестирования)
|
||||
- icon - кастомная иконка приложения
|
||||
- Actions в уведомлениях (кнопки "Ответить", "Прочитано")
|
||||
|
||||
Reference in New Issue
Block a user