fix: correct UTC/localtime mismatch in skip_repeated_notifications cooldown - #1738
Conversation
Next release
Currently translated at 67.0% (557 of 831 strings) Translation: NetAlertX/core Translate-URL: https://hosted.weblate.org/projects/pialert/core/nb_NO/
Currently translated at 48.7% (405 of 831 strings) Translation: NetAlertX/core Translate-URL: https://hosted.weblate.org/projects/pialert/core/pt_BR/
Currently translated at 80.9% (673 of 831 strings) Translation: NetAlertX/core Translate-URL: https://hosted.weblate.org/projects/pialert/core/pl/
Currently translated at 53.9% (448 of 831 strings) Translation: NetAlertX/core Translate-URL: https://hosted.weblate.org/projects/pialert/core/tr/
Currently translated at 81.1% (674 of 831 strings) Translation: NetAlertX/core Translate-URL: https://hosted.weblate.org/projects/pialert/core/ar/
tz/LOCALE were evaluated once as module-level consts at script-load time. clearCache() (the header reload button) wipes localStorage right before reloading, so that reload could read an empty settings cache, fall back to the hardcoded 'Europe/Berlin' default, and stay locked to that wrong value for the rest of the page's life. Moved the reads inside localizeTimestamp() so they're evaluated fresh on every call instead.
Fix: clock shows wrong timezone after header reload (#1640)
…own comparison; add UTC regression tests Co-authored-by: jokob-sk <96159884+jokob-sk@users.noreply.github.com>
| sys.path.extend([f"{INSTALL_PATH}/server"]) | ||
|
|
||
|
|
||
| def _make_db(): |
There was a problem hiding this comment.
do not create db mocks directly, use existing main/test/db_test_helpers.py if needed
There was a problem hiding this comment.
Updated in commit e5e1e7b — the test now imports make_db, minutes_ago, and DummyDB from db_test_helpers instead of creating its own DB mock.
| skip_repeated_notifications(db) | ||
|
|
||
| self.assertEqual( | ||
| self._get_flag(con, "AA:BB:CC:DD:EE:03"), |
There was a problem hiding this comment.
mac should be always lower case
There was a problem hiding this comment.
Fixed in commit e5e1e7b — all MACs are now lowercase (e.g. aa:bb:cc:dd:ee:01).
Co-authored-by: jokob-sk <96159884+jokob-sk@users.noreply.github.com>
|
@copilot target the next_release branch, not main |
The code changes are already on the |
devSkipRepeatedwas silently ineffective in any timezone ahead of UTC. SQLite's'localtime'modifier on the RHS inflated "now" by the UTC offset (e.g. +7200s for UTC+2), making the cooldown window appear expired even for genuinely-recent notifications. A 2-hour cooldown in Europe/Warsaw DST provided zero suppression whatsoever.Root cause — one-word SQL modifier in
server/messaging/reporting.py:devLastNotificationis stored as UTC; the comparison must use UTC on both sides.Changes:
server/messaging/reporting.py— remove'localtime'from thestrftimecalltest/backend/test_skip_repeated_notifications.py— four new unit tests:devSkipRepeated=0→ never suppresses🔍 Related Issues
📋 Type of Change
📷 Screenshots or Logs (if applicable)
Before fix (UTC+2,
devSkipRepeated=2, last notification 20 min ago):🧪 Testing Steps
PYTHONPATH=server python -m unittest test.backend.test_skip_repeated_notifications -v— all 4 tests pass.✅ Checklist
🙋 Additional Notes
Note:
app.conf'sTIMEZONEsetting does not affect SQLite's'localtime'modifier — that reads the OS/processTZ. The bug only manifests when the container's actualTZis non-UTC.