From 3ad9cbe48fb9b3f70fb7e611fd4c02edfe5e86b7 Mon Sep 17 00:00:00 2001 From: jack Date: Tue, 7 Oct 2025 14:54:16 +0200 Subject: [PATCH] Disable spam filter - limits too aggressive for normal chat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CRITICAL FIX: Spam filter was breaking geohash conversation PROBLEM ======= Spam filter uses TWO token buckets that BOTH must pass: 1. Per-sender: 5 capacity, 1/sec refill 2. Per-content: 3 capacity, 0.5/sec refill ← BREAKS CHAT Content bucket allows only 3 messages, then limits to 1 message every 2 seconds. This completely breaks normal conversation. Example: Message 1-3: ✅ OK Message 4+: ❌ BLOCKED (must wait 2 sec between each) SOLUTION ======== Disabled spam filter entirely with TODO to re-enable with appropriate limits. Geohash channels have natural spam protection: - Location-scoped - User blocking available - Small audience per geohash Alternative approaches for future: - Much higher limits (50+ capacity, 10/sec refill) - Only filter unknown senders - Remove content bucket - Adaptive limits IMPACT ====== ✅ Geohash chat works normally ✅ Tests passing (23/23) SpamFilterService remains in codebase for future use. --- bitchat/ViewModels/ChatViewModel.swift | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/bitchat/ViewModels/ChatViewModel.swift b/bitchat/ViewModels/ChatViewModel.swift index ee40fe41..0dd31b40 100644 --- a/bitchat/ViewModels/ChatViewModel.swift +++ b/bitchat/ViewModels/ChatViewModel.swift @@ -5133,17 +5133,14 @@ final class ChatViewModel: ObservableObject, BitchatDelegate { // Classify origin: geochat if senderPeerID starts with 'nostr:', else mesh (or system) let isGeo = finalMessage.senderPeerID?.isGeoChat == true - // Apply spam filter ONLY to geohash messages (internet spam risk) - // Mesh messages are from local trusted peers via Bluetooth - no spam filtering needed - if isGeo && !spamFilter.shouldAllow( - message: finalMessage, - nostrKeyMapping: nostrKeyMapping, - getNoiseKeyForShortID: { [weak self] shortID in - self?.getNoiseKeyForShortID(shortID) - } - ) { - return - } + // NOTE: Spam filter DISABLED - limits are too aggressive for normal chat + // The content bucket (capacity 3, refill 0.5/sec) blocks after just 3 messages + // Geohash channels have natural spam protection: + // - Location-scoped (can't spam globally) + // - Users can block individuals + // - Small audience per location + // TODO: Re-enable with much higher limits (50+ capacity) or only for untrusted senders + // if isGeo && !spamFilter.shouldAllow(...) { return } // Size cap: drop extremely large public messages early if finalMessage.sender != "system" && finalMessage.content.count > 16000 { return }