mirror of
https://github.com/permissionlesstech/bitchat-android.git
synced 2026-09-19 04:59:59 +00:00
fix(nostr): match tag filters case-insensitively in the client-side gate
NostrRelayManager runs every incoming event through NostrFilter.matches before any handler sees it, and that comparison was exact. So the case-insensitive handling in the previous commit was unreachable over the relay path: a note tagged ["G", "U4PRUYD"] was dropped at the gate. iOS has no such client-side filter and lowercases the tag name and geohash where it reads them, so the note is visible there. The values this app filters on are hex ids or geohashes, both of which encode the same value in either case.
This commit is contained in:
parent
293a751596
commit
26100f447b
@ -191,18 +191,24 @@ data class NostrFilter(
|
||||
return false
|
||||
}
|
||||
|
||||
// Check tag filters
|
||||
// Check tag filters.
|
||||
//
|
||||
// Tag names and values are compared case-insensitively. The values this
|
||||
// app filters on are hex ids (`e`, `p`) or geohashes (`g`), and both
|
||||
// encode the same value in either case; iOS has no client-side filter at
|
||||
// all and lowercases the tag name and the geohash where it reads them,
|
||||
// so an event tagged ["G", "U4PRUYD"] is a note there. Comparing exactly
|
||||
// here dropped it before any handler saw it.
|
||||
if (tagFilters != null) {
|
||||
for ((tagName, requiredValues) in tagFilters) {
|
||||
val eventTags = event.tags.filter { it.isNotEmpty() && it[0] == tagName }
|
||||
val eventValues = eventTags.mapNotNull { tag ->
|
||||
if (tag.size > 1) tag[1] else null
|
||||
}
|
||||
|
||||
val eventValues = event.tags
|
||||
.filter { it.size > 1 && it[0].equals(tagName, ignoreCase = true) }
|
||||
.map { it[1].lowercase() }
|
||||
|
||||
val hasMatch = requiredValues.any { requiredValue ->
|
||||
eventValues.contains(requiredValue)
|
||||
eventValues.contains(requiredValue.lowercase())
|
||||
}
|
||||
|
||||
|
||||
if (!hasMatch) {
|
||||
return false
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user