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
@@ -59,6 +59,12 @@ class ChannelMessage {
|
||||
final String? replyToText;
|
||||
final Map<String, List<String?>> reactions;
|
||||
|
||||
/// Set when the message filter hid this message (a FilterReason JSON name).
|
||||
final String? filterReason;
|
||||
|
||||
/// Extra context for [filterReason], e.g. the matching rule pattern.
|
||||
final String? filterDetail;
|
||||
|
||||
ChannelMessage({
|
||||
this.senderKey,
|
||||
required this.senderName,
|
||||
@@ -86,6 +92,8 @@ class ChannelMessage {
|
||||
this.replyToSenderName,
|
||||
this.replyToText,
|
||||
Map<String, List<String?>>? reactions,
|
||||
this.filterReason,
|
||||
this.filterDetail,
|
||||
}) : messageId =
|
||||
messageId ??
|
||||
'${timestamp.millisecondsSinceEpoch}_${senderName.hashCode}_${text.hashCode}',
|
||||
@@ -97,6 +105,8 @@ class ChannelMessage {
|
||||
pathVariants,
|
||||
);
|
||||
|
||||
bool get isFiltered => filterReason != null;
|
||||
|
||||
String? get senderKeyHex =>
|
||||
senderKey != null ? pubKeyToHex(senderKey!) : null;
|
||||
|
||||
@@ -125,6 +135,9 @@ class ChannelMessage {
|
||||
Object? translationModelId = _unset,
|
||||
Map<String, List<String?>>? reactions,
|
||||
int? channelIndex,
|
||||
String? filterReason,
|
||||
String? filterDetail,
|
||||
bool clearFilter = false,
|
||||
}) {
|
||||
return ChannelMessage(
|
||||
senderKey: senderKey,
|
||||
@@ -161,6 +174,8 @@ class ChannelMessage {
|
||||
replyToSenderName: replyToSenderName ?? this.replyToSenderName,
|
||||
replyToText: replyToText ?? this.replyToText,
|
||||
reactions: reactions ?? this.reactions,
|
||||
filterReason: clearFilter ? null : (filterReason ?? this.filterReason),
|
||||
filterDetail: clearFilter ? null : (filterDetail ?? this.filterDetail),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user