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:
zjs81 committed 2026-11-05 23:35:27 -07:00
1 parent 5ef2c2cd7d
commit 1332c35884
75 files changed
+12527 -254

No files matched your search

+8
View File
@@ -21,6 +21,7 @@ import 'services/image_codec_settings_store.dart';
import 'services/received_image_blob_store_factory.dart';
import 'services/received_image_store.dart';
import 'services/storage_service.dart';
import 'services/message_filter/message_filter_service.dart';
import 'services/message_retry_service.dart';
import 'services/path_history_service.dart';
import 'services/app_settings_service.dart';
@@ -78,6 +79,7 @@ void main() async {
final translationService = TranslationService(appSettingsService);
final uiViewStateService = UiViewStateService();
final timeoutPredictionService = TimeoutPredictionService(storage);
final messageFilterService = MessageFilterService();
// Load settings before anything reads them. The image stack below takes its
// model registry and its "process automatically" default straight off
@@ -168,6 +170,7 @@ void main() async {
await receivedImageStore.load();
await uiViewStateService.initialize();
await timeoutPredictionService.initialize();
await messageFilterService.load();
// Wire up connector with services
connector.initialize(
@@ -182,6 +185,7 @@ void main() async {
imageCodecService: imageCodecService,
imageTransport: imageTransport,
receivedImageStore: receivedImageStore,
messageFilterService: messageFilterService,
// ImageStreamReassembler.addChunk already forwards every outcome to the
// store together with the channel index (which ImageChunkOutcome itself
// does not carry), so onImageChunk would be a second, channel-blind path.
@@ -216,6 +220,7 @@ void main() async {
imageReassembler: imageReassembler,
networkMapUploadService: networkMapUploadService,
chatBackgroundService: chatBackgroundService,
messageFilterService: messageFilterService,
),
);
}
@@ -362,6 +367,7 @@ class MeshCoreApp extends StatefulWidget {
final ImageStreamReassembler imageReassembler;
final NetworkMapUploadService networkMapUploadService;
final ChatBackgroundService chatBackgroundService;
final MessageFilterService messageFilterService;
const MeshCoreApp({
super.key,
@@ -382,6 +388,7 @@ class MeshCoreApp extends StatefulWidget {
required this.imageReassembler,
required this.networkMapUploadService,
required this.chatBackgroundService,
required this.messageFilterService,
});
@override
@@ -475,6 +482,7 @@ class _MeshCoreAppState extends State<MeshCoreApp> with WidgetsBindingObserver {
ChangeNotifierProvider.value(value: widget.receivedImageStore),
ChangeNotifierProvider.value(value: widget.networkMapUploadService),
ChangeNotifierProvider.value(value: widget.chatBackgroundService),
ChangeNotifierProvider.value(value: widget.messageFilterService),
],
child: Consumer<AppSettingsService>(
builder: (context, settingsService, child) {