mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 12:25:19 +00:00
Fix/geohash blocks (#483)
* fix(geo-block): enable block/unblock for geohash users and enforce blocks\n\n- Add persisted set of blocked Nostr pubkeys in SecureIdentityStateManager\n- Check Nostr blocks for incoming messages (public + geo DMs)\n- Prevent sending geo DMs to blocked users\n- Extend /block and /unblock to resolve geohash display names to pubkeys and act accordingly\n- Improve /block list to show geohash blocks (visible names or #suffix) * fix(geo-block): enforce blocks on geohash public and DM receive; add block/unblock actions to geohash people list * fix: mark handlePublicMessage as @MainActor to call isMessageBlocked safely * ui(block): show blocked indicator (nosign icon) next to blocked peers in mesh and geohash lists * fix(geo-block): early-drop blocked pubkeys on geohash receive; filter blocked users from participants list * fix(geo-block): purge existing geohash messages/DMs on block; block directly from chat using Nostr sender ID when available --------- Co-authored-by: jack <jackjackbits@users.noreply.github.com>
This commit is contained in:
@@ -149,6 +149,9 @@ struct IdentityCache: Codable {
|
||||
// Last interaction timestamps (privacy: optional)
|
||||
var lastInteractions: [String: Date] = [:]
|
||||
|
||||
// Blocked Nostr pubkeys (lowercased hex) for geohash chats
|
||||
var blockedNostrPubkeys: Set<String> = []
|
||||
|
||||
// Schema version for future migrations
|
||||
var version: Int = 1
|
||||
}
|
||||
@@ -222,4 +225,4 @@ enum ConnectionQuality {
|
||||
}
|
||||
|
||||
// MARK: - Migration Support
|
||||
// Removed LegacyFavorite - no longer needed
|
||||
// Removed LegacyFavorite - no longer needed
|
||||
|
||||
@@ -335,6 +335,30 @@ class SecureIdentityStateManager {
|
||||
self.saveIdentityCache()
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Geohash (Nostr) Blocking
|
||||
|
||||
func isNostrBlocked(pubkeyHexLowercased: String) -> Bool {
|
||||
queue.sync {
|
||||
return cache.blockedNostrPubkeys.contains(pubkeyHexLowercased.lowercased())
|
||||
}
|
||||
}
|
||||
|
||||
func setNostrBlocked(_ pubkeyHexLowercased: String, isBlocked: Bool) {
|
||||
let key = pubkeyHexLowercased.lowercased()
|
||||
queue.async(flags: .barrier) {
|
||||
if isBlocked {
|
||||
self.cache.blockedNostrPubkeys.insert(key)
|
||||
} else {
|
||||
self.cache.blockedNostrPubkeys.remove(key)
|
||||
}
|
||||
self.saveIdentityCache()
|
||||
}
|
||||
}
|
||||
|
||||
func getBlockedNostrPubkeys() -> Set<String> {
|
||||
queue.sync { cache.blockedNostrPubkeys }
|
||||
}
|
||||
|
||||
// MARK: - Ephemeral Session Management
|
||||
|
||||
@@ -464,4 +488,4 @@ class SecureIdentityStateManager {
|
||||
return cache.verifiedFingerprints
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user