Skip to content

Notification rate limiting#110

Merged
wel97459 merged 9 commits into
zjs81:mainfrom
rsp2k:dev
Feb 9, 2026
Merged

Notification rate limiting#110
wel97459 merged 9 commits into
zjs81:mainfrom
rsp2k:dev

Conversation

@rsp2k

@rsp2k rsp2k commented Jan 27, 2026

Copy link
Copy Markdown
Contributor

First time I connected to the Idaho mesh, the app blasted me with 29 separate notifications - one for every node already on the network. Kinda ironic that the flood management protocol flooded my phone.

Now it batches rapid notifications with a 5-second window and shows a single summary ("29 new nodes") instead. Added debug logging that shows device names without exposing message content, so logs are safe to share in bug reports.

- Add batching system to prevent notification storms (3s rate limit, 5s batch window)
- Queue rapid notifications and show batch summaries
- Debug logs show device names for adverts, sender/channel for messages (no content leaks)
- Remove unused _maxBatchSize constant

Context: Added after getting notification-flooded while evaluating RF flood management. The irony.
@446564

446564 commented Feb 1, 2026

Copy link
Copy Markdown
Collaborator

@rsp2k looks like there are some conflicts, can you please review and mark ready for review after you have done so?

Thanks very much 😎

@wel97459

wel97459 commented Feb 1, 2026

Copy link
Copy Markdown
Collaborator

I'll try it out. thanks for making the PR.

I made a mistake and removed this
@wel97459

wel97459 commented Feb 1, 2026

Copy link
Copy Markdown
Collaborator

Will need to add the text strings to the l10n translations system, to the fixed text.

rsp2k added 4 commits February 6, 2026 02:05
Resolved conflict in notification_service.dart:
- Kept _getNotificationIdentifier (needed for rate limiting debug logs)
- Dropped _truncateMessage (main simplified channel message preview)
Addresses PR zjs81#110 review feedback to use the translations system:
- Add notification strings to app_en.arb (plurals for batch summary)
- Update NotificationService to use lookupAppLocalizations()
- Wire locale from MaterialApp to NotificationService
- Regenerate localization files

New strings added (English only, translations needed):
- notification_activityTitle: "MeshCore Activity"
- notification_messagesCount: "{count} message(s)"
- notification_channelMessagesCount: "{count} channel message(s)"
- notification_newNodesCount: "{count} new node(s)"
- notification_newTypeDiscovered: "New {type} discovered"
- notification_receivedNewMessage: "Received new message"
# Conflicts:
#	lib/services/notification_service.dart
Translated notification_activityTitle, notification_messagesCount,
notification_channelMessagesCount, notification_newNodesCount,
notification_newTypeDiscovered, and notification_receivedNewMessage
to: bg, de, es, fr, it, nl, pl, pt, ru, sk, sl, sv, uk, zh

Includes proper ICU plural forms for Slavic languages (few/many/other)
and Slovenian dual form.
@rsp2k

rsp2k commented Feb 7, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the l10n feedback - notification strings are now integrated into the translations system.

Changes:

  • Added setLocale() to NotificationService using lookupAppLocalizations() for context-free l10n access
  • Wired up locale in MaterialApp.builder
  • Added 6 notification string keys to all 14 supported languages:
    • notification_activityTitle
    • notification_messagesCount (with plural forms)
    • notification_channelMessagesCount (with plural forms)
    • notification_newNodesCount (with plural forms)
    • notification_newTypeDiscovered
    • notification_receivedNewMessage

Includes proper ICU plural handling for Slavic languages (few/many/other forms) and Slovenian dual form.

Build passes flutter analyze and flutter build apk.

@rsp2k rsp2k marked this pull request as ready for review February 7, 2026 10:48
@446564

446564 commented Feb 7, 2026

Copy link
Copy Markdown
Collaborator

Can you please also run dart format on your changes? 😊

@wel97459

wel97459 commented Feb 7, 2026

Copy link
Copy Markdown
Collaborator

Ya I just didn't know to do that.

@446564 446564 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels odd that only the last message in a channel is in the notification, but I suppose you can't have them all.

I haven't noticed any issues running this and scanned over the code.

But it looks good to me, and when there are too many like on reconnect it aggregates into a count.

Resolves conflicts in l10n files by keeping both:
- notification_* strings (from dev/PR zjs81#110)
- settings_gpxExport* strings (from main)
@wel97459 wel97459 merged commit daca427 into zjs81:main Feb 9, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants