Uses the new isHex64 in the ContactList

This commit is contained in:
Vitor Pamplona
2025-10-03 15:58:38 -04:00
parent 7994945209
commit b002f9f37e
2 changed files with 8 additions and 3 deletions

View File

@@ -58,13 +58,13 @@ class ContactListEvent(
/**
* Returns a list of p-tags that are verified as hex keys.
*/
fun verifiedFollowKeySet(): Set<HexKey> = tags.mapNotNullTo(HashSet(), ContactTag::parseValidKey)
fun verifiedFollowKeySet(): Set<HexKey> = tags.mapNotNullTo(mutableSetOf(), ContactTag::parseValidKey)
/**
* Returns a list of a-tags that are verified as correct.
*/
@Deprecated("Use CommunityListEvent instead.")
fun verifiedFollowAddressSet(): Set<HexKey> = tags.mapNotNullTo(HashSet(), ATag::parseValidAddress)
fun verifiedFollowAddressSet(): Set<HexKey> = tags.mapNotNullTo(mutableSetOf(), ATag::parseValidAddress)
fun unverifiedFollowKeySet() = tags.mapNotNull(ContactTag::parseKey)

View File

@@ -28,6 +28,7 @@ import com.vitorpamplona.quartz.nip01Core.hints.types.PubKeyHint
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.NormalizedRelayUrl
import com.vitorpamplona.quartz.nip01Core.relay.normalizer.RelayUrlNormalizer
import com.vitorpamplona.quartz.nip19Bech32.decodePublicKey
import com.vitorpamplona.quartz.utils.Hex
import com.vitorpamplona.quartz.utils.Log
import com.vitorpamplona.quartz.utils.arrayOfNotNull
import com.vitorpamplona.quartz.utils.bytesUsedInMemory
@@ -100,7 +101,11 @@ data class ContactTag(
ensure(tag[0] == TAG_NAME) { return null }
ensure(tag[1].length == 64) { return null }
return try {
decodePublicKey(tag[1]).toHexKey()
if (Hex.isHex64(tag[1])) {
tag[1]
} else {
null
}
} catch (e: Exception) {
Log.w("ContactListEvent", "Can't parse contact list pubkey ${tag.joinToString(", ")}", e)
null