mirror of
https://github.com/permissionlesstech/bitchat-android.git
synced 2026-07-25 11:25:21 +00:00
Fix geohash filtering (#376)
* fix(geohash): enforce client-side filter on subscription and validate 'g' tag in handler; move dedup after validation; avoid misrouting events across geohashes * cleanup duplicate code block * remove
This commit is contained in:
@@ -1167,13 +1167,24 @@ class NostrGeohashService(
|
||||
private fun handleUnifiedGeohashEvent(event: NostrEvent, geohash: String) {
|
||||
coroutineScope.launch(Dispatchers.Default) {
|
||||
try {
|
||||
Log.v(TAG, "🔍 handleUnifiedGeohashEvent called - eventGeohash: $geohash, currentGeohash: $currentGeohash, eventKind: ${event.kind}, eventId: ${event.id.take(8)}...")
|
||||
Log.v(TAG, "🔍 handleUnifiedGeohashEvent called - subGeohash: $geohash, currentGeohash: $currentGeohash, kind: ${event.kind}, id: ${event.id.take(8)}...")
|
||||
|
||||
// Only handle ephemeral kind 20000 events
|
||||
if (event.kind != 20000) {
|
||||
Log.v(TAG, "❌ Skipping non-ephemeral event (kind ${event.kind})")
|
||||
return@launch
|
||||
}
|
||||
|
||||
// VALIDATE EVENT G TAG AGAINST SUBSCRIPTION GEOHASH
|
||||
val eventGeohash = event.tags.firstOrNull { it.size >= 2 && it[0] == "g" }?.getOrNull(1)
|
||||
if (eventGeohash == null) {
|
||||
Log.w(TAG, "🚫 Dropping kind=20000 without 'g' tag id=${event.id.take(8)}")
|
||||
return@launch
|
||||
}
|
||||
if (!eventGeohash.equals(geohash, ignoreCase = true)) {
|
||||
Log.w(TAG, "🚫 Dropping mismatched geohash event: sub=$geohash eventTag=$eventGeohash id=${event.id.take(8)}")
|
||||
return@launch
|
||||
}
|
||||
|
||||
// Check Proof of Work validation BEFORE other processing
|
||||
val powSettings = PoWPreferenceManager.getCurrentSettings()
|
||||
|
||||
Reference in New Issue
Block a user