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

+2
View File
@@ -30,6 +30,7 @@ MeshCore Open is an open-source Flutter client for MeshCore LoRa mesh networking
17. [Review Mode](review-mode.md) - Simulated radio and reviewer instructions for Google Play and App Store review
18. [Network Map](network-map.md) - Online repeater map, adding and managing repeaters from it, opt-in uploads, and hiding a repeater
19. [Themes](themes.md) - Color themes, custom icons and map markers, chat backgrounds, automatic holiday themes, and holiday message animations
20. [Message Filter](message-filter.md) - Hide spam and repeated channel messages with your own rules, automatic checks, and learning from Spam taps, all on the device
## App Overview
@@ -45,6 +46,7 @@ MeshCore Open connects to MeshCore LoRa mesh radios over BLE, USB, or TCP. Once
- **Configure radio settings** including frequency, power, bandwidth, and spreading factor
- **Cache offline maps** for use without internet connectivity
- **Analyze line-of-sight** between nodes with terrain elevation profiles
- **Filter spam** in channels with your own rules and automatic on-device checks
- **Use Android Auto** to hear new messages and reply by voice while driving (Android)
## What needs internet?
+5
View File
@@ -101,6 +101,10 @@ Messages also show a region label when known, independently of message tracing.
- **URL image previews** when enabled per channel; content is fetched over the internet
- **Reactions** displayed as emoji pills below target messages
### Message Filter
The app bar overflow menu (⋮) has **Filter messages in this channel** (shown while the master switch is on) to turn the [message filter](message-filter.md) on or off for just this channel. Hidden messages do not count as unread, notify, or appear in the channel list preview.
### Replies (Channel Chat Only)
- **Mobile**: Swipe an **incoming** message left to trigger reply (with haptic feedback). You cannot swipe your own outgoing messages. Swipe reply is not available on desktop.
@@ -128,6 +132,7 @@ Where your radio only hears nearby repeaters, turn on **Also count different nea
| Reply | All messages | Triggers reply mode |
| Path | All messages | Opens message path view |
| Add Reaction | Incoming messages only | Opens emoji picker (cannot react to your own messages) |
| Mark as spam / Filter this sender / Filter messages like this… | Incoming messages (when filtering is on for the channel) | Hides spam; see [Message filter](message-filter.md) |
| Copy | All messages | Copies text to clipboard |
| Mark as Unread | Incoming messages only | Marks this message and all subsequent incoming messages as unread |
| Delete | All messages | Removes locally (not from mesh) |
+2
View File
@@ -126,6 +126,8 @@ Add emoji reactions to incoming messages (not your own):
| Retry | Failed outgoing messages | Re-sends the message |
| Open chat with sender | Room server chats | Opens 1:1 chat with the message sender |
In channel chats the menu also offers **Mark as spam**, **Filter this sender** and **Filter messages like this…**; see [Message filter](message-filter.md). Direct messages are never filtered.
## Image and translation setup
Enable URL images in the contact’s chat settings to preview supported image links; see [URL images](additional-features.md#url-image-previews). Images and files can also be uploaded to a configured IPFS provider from the **+** menu in direct or channel chat; the resulting URL is sent as ordinary text. See [sharing via IPFS](additional-features.md#share-an-image-via-ipfs) and [IPFS provider configuration](settings.md#ipfs-provider-configuration). Mesh image packets are currently sent through channel chat, not the direct-message composer. Set up translation and download a model in [App Settings](settings.md#translation) before using incoming or pre-send translation.
+109
View File
@@ -0,0 +1,109 @@
# Message Filter
The message filter hides spam and repeated messages in channel chats. It runs entirely on your phone or computer: nothing is downloaded, no AI model or internet connection is needed, and nothing is sent over the mesh. Filtered messages are never deleted. You can always view them again.
## Overview
- Works on **channel messages only**. Direct messages are never filtered.
- Your own messages, reactions, GIFs and location pins are never filtered.
- Filtering is on by default, with sensible automatic checks.
- You can add your own rules, tell the app what is spam, and turn filtering off for a single channel.
## How to Access
- **Settings → Message filter**: the full settings screen (listed under App Settings on the Settings screen).
- **Channel chat → ⋮ menu → Filter messages in this channel**: turn filtering on or off for that channel only.
- **Long-press a message** in a channel chat for the Mark as spam, Filter this sender and Filter messages like this… actions.
## How it works
Each new incoming channel message is checked in this order. The first check that matches decides:
1. **Sender rule**: one of your rules matches the sender's name.
2. **Text rule**: one of your rules matches the message text.
3. **Repeated characters** (automatic): the same character 8 or more times in a row, such as "aaaaaaaa" or "!!!!!!!!".
4. **Repeated messages** (automatic):
- The **same sender** sends the same message again within 10 minutes.
- The **same text from 3 or more different senders** within 30 minutes. This only applies to longer messages, at least 10 characters and at least 6 words, so short greetings such as "Happy New Year!" are never caught.
5. **Learned from your Spam taps** (automatic): the app compares the message with messages you marked as spam. This needs at least 2 messages marked as spam and 80% confidence.
Details worth knowing:
- Time windows use the time the message was **sent**, not when it reached your phone. History that is synced after you reconnect is not mistaken for a flood.
- Rules ignore capital letters, accents, zero-width (invisible) characters and look-alike letters (for example Cyrillic or Greek letters that look like Latin ones, or fullwidth letters), so spammers cannot easily sneak around a rule.
- Repeated-message checks also ignore punctuation, emoji and `@[name]` mentions.
- A reply's leading `@[name]` mention is not part of the text that is checked.
## Marking messages yourself
Long-press (or right-click) an incoming channel message:
| Action | What it does |
|---|---|
| **Mark as spam** | Hides the message now and teaches the automatic filter ("Marked as spam"). |
| **Not spam** | Shown instead of Mark as spam on a filtered message. Shows it again, stops the same text being caught as a repeat in this channel while the app is running, and teaches the filter ("Marked as not spam"). |
| **Filter this sender** | After a confirmation ("Hide all messages from ...?"), adds a Sender name rule with the Exact match for that name. |
| **Filter messages like this…** | Opens the rule editor with the message text filled in, so you can shorten it to the key phrase and choose how to match. |
These actions are not offered on your own messages, on GIFs or location pins, or in channels where filtering is off.
## Your rules
In **Message filter → Your rules**, tap **Add rule**. Each rule has:
| Option | Choices |
|---|---|
| **Word, phrase or name** | The text to look for (for example `meshos`). |
| **Look in** | **Message text**, **Sender name**, or **Both**. |
| **Match** | **Contains** (anywhere), **Whole word** (not inside a longer word) or **Exact** (the whole text or name). |
Tap a rule to edit it. Each rule has its own on/off switch and a delete button. Deleting shows "Rule deleted" with an Undo button.
## How filtered messages look
Under **Message filter → Filtered messages** choose one of two display modes:
- **Show a small placeholder** (default): hidden messages are replaced by a small line, "Hidden message · Tap to view". Several hidden messages in a row collapse into one line, for example "3 hidden messages · Tap to view".
- Tap the line to open it with a short animation. The header then reads "Showing hidden message · Tap to hide"; tap it again to close.
- Each opened message shows why it was filtered (for example `Filtered: matches "meshos"`, `Filtered: repeated message` or `Filtered: you marked this as spam`) with **Not spam** and **Hide** buttons.
- **Hide completely**: nothing is shown in the chat. "Hidden messages stay in the Filtered messages list."
The **Filtered messages (n)** entry on the settings screen opens a list of everything that was filtered, newest first, across all channels. Tap a row to view it, or tap **Not spam** to restore it.
Other effects of filtering:
- Filtered messages never count as **unread** and never send a **notification**.
- They are not **auto-translated**.
- They are not used as the **last-message preview** in the Channels list; the newest message that was not hidden is shown instead.
- If someone replies to a hidden message, the quoted text in the reply is concealed ("Hidden message · Tap to view") until the original is opened.
## Settings
| Setting | Default | Description |
|---|---|---|
| **Filter messages** | On | Master switch. "Applies to channel messages". |
| **Show a small placeholder** / **Hide completely** | Placeholder | How filtered messages appear in chat. |
| **Your rules** | None | Your own rules (see above). |
| **Repeated messages** | On | "The same message sent again, or by several senders". |
| **Repeated characters** | On | Messages like "aaaaaaaa" or "!!!!!!!!". |
| **Learn from Spam taps** | On | Shows how many "spam and not-spam examples" the app is using. |
| **Reset learning** | | Asks for confirmation, then forgets everything learned from your Spam and Not spam taps. Your rules are kept. |
### Channel menu
In a channel chat, open the ⋮ menu and tick or untick **Filter messages in this channel**. This item is only shown while the master switch is on. Channels you untick are not filtered at all (no rules, no automatic checks), and their messages show normally.
## Privacy
Rules, settings and the examples used for learning are stored on your device in the app's preferences. They are **global**: they apply to every radio you connect, unlike most per-radio data. Nothing is uploaded and nothing is shared. The learning is a small statistical check that runs in the app itself; there is no model to download.
## Limitations
- **Channels only.** Direct messages and room chats are not filtered.
- **New messages only.** A new rule or a changed switch applies to messages received from then on, not to messages already in the chat. Use Mark as spam on an old message to hide it.
- **Reveal lasts while the chat is open.** Messages you open stay open until you tap the "Tap to hide" header (or Hide on one of them) or leave the chat; they collapse again next time.
- **Learning is per device.** It is not shared between your phones or computers, and it needs at least 2 Spam taps before it does anything.
- **Repeat tracking is not remembered.** The recent-message memory used for repeat checks is kept only while the app is running.
- **Filtering happens in the app.** Spam still travels over the radio channel and uses airtime; the filter only keeps it from your screen.
See also [Channels](channels.md), [Chat & Messaging](chat-and-messaging.md), [Notifications](notifications.md) and [Settings](settings.md).
+1 -1
View File
@@ -93,7 +93,7 @@ The app icon (iOS) or dock icon (macOS) badge shows the total unread count. It i
- Stored per contact (by public key) and per channel, **scoped to the connected device's identity** (first 10 hex characters of its public key). Switching between different radios gives each its own independent unread state
- **Suppressed when viewing**: Opening a chat resets the count to 0 and cancels the OS notification
- **Ignored for**: Outgoing messages, CLI messages, and repeater contacts
- **Ignored for**: Outgoing messages, CLI messages, repeater contacts, and channel messages hidden by the [message filter](message-filter.md) (these also never send a notification)
- Debounced writes (500ms) to avoid excessive storage I/O during message bursts
## Notification Settings
+4
View File
@@ -188,6 +188,10 @@ Controls character substitution profiles used to render Cyrillic text in Latin c
---
### Message filter
On the Settings screen, below App Settings, **Message filter** opens a page to hide spam and repeated channel messages: a master switch, display mode, your own rules, automatic checks, and learning. See [Message Filter](message-filter.md).
## Actions
One-tap device operations: