mirror of
https://github.com/permissionlesstech/bitchat-android.git
synced 2026-08-15 06:56:30 +00:00
fix(nostr): prevent subscription leak on JSON parse failure
Move resolved=true after successful parse so timeout cleanup still runs if metadata content is invalid JSON. Fixes dangling subscriptions and permanently pending pubkeys.
This commit is contained in:
parent
7afab46dc0
commit
411541faf5
@ -531,12 +531,12 @@ object NostrIdentityBridge {
|
||||
id = subscriptionId,
|
||||
handler = { event ->
|
||||
if (!resolved && event.kind == NostrKind.METADATA && event.pubkey == pubkeyHex) {
|
||||
resolved = true
|
||||
try {
|
||||
val profileJson = com.google.gson.JsonParser.parseString(event.content).asJsonObject
|
||||
val name = profileJson.get("name")?.asString?.takeIf { it.isNotBlank() }
|
||||
?: profileJson.get("display_name")?.asString?.takeIf { it.isNotBlank() }
|
||||
|
||||
resolved = true
|
||||
relayManager.unsubscribe(subscriptionId)
|
||||
|
||||
GlobalScope.launch(Dispatchers.Main) {
|
||||
@ -544,6 +544,7 @@ object NostrIdentityBridge {
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "Failed to parse profile for $pubkeyHex: ${e.message}")
|
||||
// Don't mark as resolved - let timeout or next event retry
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user