Add channel message filter for spam and repeated messages
Client-side filter for channel messages, with no model download: - User rules on message text and/or sender name (contains, whole word, exact), normalised for case, accents, zero-width and look-alike letters. - Automatic checks: repeated characters, same-sender repeats within 10 minutes, and the same sentence (>= 6 words) from 3+ senders within 30 minutes. Windows use send times, so synced history is not a flood. - On-device n-gram classifier trained by Mark as spam / Not spam taps. Filtered messages are kept, never notify or count as unread, are not auto-translated or used for channel previews, and are concealed in reply quotes. They show as a calm, collapsible placeholder that animates open and closed, or can be hidden completely. Includes a Filtered messages list, per-channel toggle, settings screen, translations for all locales and documentation.
This commit is contained in:
1 parent
5ef2c2cd7d
commit
1332c35884
75 files changed
+12527
-254
No files matched your search
@@ -12,6 +12,7 @@ import '../connector/meshcore_connector.dart';
|
||||
import '../l10n/l10n.dart';
|
||||
import '../services/app_settings_service.dart'
|
||||
show AppSettingsService, ChannelNotificationMode;
|
||||
import '../services/message_filter/message_filter_service.dart';
|
||||
import '../services/ui_view_state_service.dart';
|
||||
import '../models/channel.dart';
|
||||
import '../models/community.dart';
|
||||
@@ -102,6 +103,12 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
||||
Widget build(BuildContext context) {
|
||||
final connector = context.watch<MeshCoreConnector>();
|
||||
final viewState = context.watch<UiViewStateService>();
|
||||
// Previews and "latest" sorting depend on per-channel filter settings.
|
||||
try {
|
||||
context.watch<MessageFilterService>();
|
||||
} on ProviderNotFoundException {
|
||||
// No message filter in this tree (tests); previews ignore it.
|
||||
}
|
||||
|
||||
// Auto-navigate back to scanner if disconnected
|
||||
if (!checkConnectionAndNavigate(connector)) {
|
||||
@@ -426,9 +433,9 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
||||
iconColor = MeshPalette.blue;
|
||||
}
|
||||
|
||||
// Last message preview
|
||||
final messages = connector.getChannelMessages(channel);
|
||||
final lastMessage = messages.isNotEmpty ? messages.last : null;
|
||||
// Last message preview. Messages hidden by the message filter never
|
||||
// become the preview.
|
||||
final lastMessage = connector.latestVisibleChannelMessage(channel);
|
||||
final lastMessageText = lastMessage?.text ?? '';
|
||||
final lastPreview =
|
||||
lastMessageText.isNotEmpty &&
|
||||
@@ -774,14 +781,13 @@ class _ChannelsScreenState extends State<ChannelsScreen>
|
||||
break;
|
||||
case ChannelSortOption.latestMessages:
|
||||
filtered.sort((a, b) {
|
||||
final aMessages = connector.getChannelMessages(a);
|
||||
final bMessages = connector.getChannelMessages(b);
|
||||
final aLast = aMessages.isEmpty
|
||||
? DateTime(1970)
|
||||
: aMessages.last.timestamp;
|
||||
final bLast = bMessages.isEmpty
|
||||
? DateTime(1970)
|
||||
: bMessages.last.timestamp;
|
||||
// Filtered messages don't bump a channel, matching the preview.
|
||||
final aLast =
|
||||
connector.latestVisibleChannelMessage(a)?.timestamp ??
|
||||
DateTime(1970);
|
||||
final bLast =
|
||||
connector.latestVisibleChannelMessage(b)?.timestamp ??
|
||||
DateTime(1970);
|
||||
final timeCompare = bLast.compareTo(aLast);
|
||||
if (timeCompare != 0) return timeCompare;
|
||||
return compareByName(a, b);
|
||||
|
||||
Reference in new issue
Block a user