Doesn't crash when a non-hex key is inserted in the contact list

This commit is contained in:
Vitor Pamplona
2023-03-14 19:08:06 -04:00
parent f8bb4a3168
commit 8b53d28721

View File

@@ -23,7 +23,12 @@ class ContactListEvent(
val verifiedFollowKeySet: Set<HexKey> by lazy {
tags.filter { it[0] == "p" }.mapNotNull {
it.getOrNull(1)?.let { unverifiedHex: String ->
decodePublicKey(unverifiedHex).toHexKey()
try {
decodePublicKey(unverifiedHex).toHexKey()
} catch (e: Exception) {
Log.w("ContactListEvent", "Can't parse tags as a follows: ${it[1]}", e)
null
}
}
}.toSet()
}