tududi/backend
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
..
cmd Fix isEmail validation failure on valid emails during Docker setup (#835) 2026-02-11 15:42:11 +02:00
config Setup infra for reverse proxy (#831) 2026-02-10 20:22:51 +02:00
docs/swagger Update swagger (#906) 2026-03-04 18:47:48 +02:00
middleware Fix bug 366 (#764) 2026-01-07 18:18:07 +02:00
migrations Fix Telegram notification spam with channel-level rate limiting (#951) 2026-03-19 20:26:11 +02:00
models Fix Telegram notification spam with channel-level rate limiting (#951) 2026-03-19 20:26:11 +02:00
modules Fix Telegram notification spam with channel-level rate limiting (#951) 2026-03-19 20:26:11 +02:00
scripts Fix bug 366 (#764) 2026-01-07 18:18:07 +02:00
seeders Fix bug 366 (#764) 2026-01-07 18:18:07 +02:00
services Fix bug 366 (#764) 2026-01-07 18:18:07 +02:00
shared Fix bug 366 (#764) 2026-01-07 18:18:07 +02:00
tests Fix Telegram notification spam with channel-level rate limiting (#951) 2026-03-19 20:26:11 +02:00
utils Feat: habits (#707) 2025-12-13 08:47:52 +02:00
.env.example Setup infra for reverse proxy (#831) 2026-02-10 20:22:51 +02:00
.env.test Feat: habits (#707) 2025-12-13 08:47:52 +02:00
.prettierignore Add 'dist' paths to git & prettier ignore. 2025-07-22 11:45:14 +03:00
.prettierrc.json Linting cleanup (#99) 2025-07-01 11:40:09 +03:00
.sequelizerc Express migration (#80) 2025-06-16 21:50:44 +03:00
app.js Setup infra for reverse proxy (#831) 2026-02-10 20:22:51 +02:00
database.sqlite Fix bug 619 (#629) 2025-12-02 18:00:36 +02:00
eslint.config.js Sorting fixes (#174) 2025-07-17 17:43:56 +03:00
jest.config.js Fix E2E test breakage (#380) 2025-10-05 16:04:46 +03:00