tududi/backend/modules/tasks
Chris 11cd77bedd
Fix Telegram notification spam with channel-level rate limiting (#951)
* Fix Telegram notification spam with channel-level rate limiting

Addresses issue #950 where Telegram notifications were sent excessively
(96-288 messages per day per task) due to the delete-and-recreate pattern
added in commit 105a913a to fix navbar notification pile-up.

Changes:
- Add channel_sent_at JSON field to notifications table to track when
  each channel (telegram, email, push) was last sent
- Add helper methods to notification model:
  - markChannelAsSent(channel): Records send timestamp
  - wasChannelRecentlySent(channel, threshold): Checks if sent within 24h
- Modify sendTelegramNotification() to check rate limit before sending
- Update service layer (dueTaskService, deferredTaskService,
  dueProjectService) to preserve channel_sent_at when recreating
  notifications
- Add comprehensive unit and integration tests (20 tests, all passing)

Impact:
- Reduces Telegram notifications from 96-288/day to 1/day per item
- Preserves in-app notification refresh behavior (every 5-15 min)
- Maintains navbar pile-up fix from original commit
- Rate limit configurable (default: 24 hours)

Fixes #950

* Fix linting and formatting issues

* Fix integration test that was trying to access private function

* Fix prettier formatting in integration test
2026-03-19 20:26:11 +02:00
..
core Fix recurring tasks losing name and subtasks on status change (#886) 2026-03-01 13:17:54 +02:00
middleware Fix bug 366 (#764) 2026-01-07 18:18:07 +02:00
operations Fix bi-weekly+ recurring tasks reverting to weekly (#844) (#890) 2026-03-02 23:36:47 +02:00
queries Fix subtask ordering to prevent random reordering (#930) 2026-03-10 00:17:26 +02:00
utils Fix defer date validation for recurring task instances (#910) 2026-03-05 08:20:30 +02:00
attachments.js Fix bug 366 (#764) 2026-01-07 18:18:07 +02:00
deferredTaskService.js Fix Telegram notification spam with channel-level rate limiting (#951) 2026-03-19 20:26:11 +02:00
dueTaskService.js Fix Telegram notification spam with channel-level rate limiting (#951) 2026-03-19 20:26:11 +02:00
events.js Fix bug 366 (#764) 2026-01-07 18:18:07 +02:00
index.js Fix bug 366 (#764) 2026-01-07 18:18:07 +02:00
recurringTaskService.js Fix bi-weekly+ recurring tasks reverting to weekly (#844) (#890) 2026-03-02 23:36:47 +02:00
repository.js Fix bug 366 (#764) 2026-01-07 18:18:07 +02:00
routes.js Fix: Show Projects with due dates in Upcoming view (#928) 2026-03-09 23:36:14 +02:00
taskEventService.js Fix bug 366 (#764) 2026-01-07 18:18:07 +02:00
taskScheduler.js Fix issue with wrong path 2026-01-18 09:47:12 +02:00
taskSummaryService.js Fix Telegram task display bug by escaping backslashes (#860) 2026-02-24 14:19:45 +02:00