mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-10-11 01:34:01 +02:00
Extract checkIfValidHex()
This commit is contained in:
@@ -58,7 +58,7 @@ object LocalCache {
|
|||||||
|
|
||||||
fun checkGetOrCreateUser(key: String): User? {
|
fun checkGetOrCreateUser(key: String): User? {
|
||||||
return try {
|
return try {
|
||||||
val checkHex = Hex.decode(key).toNpub() // Checks if this is a valid Hex
|
checkIfValidHex(key)
|
||||||
getOrCreateUser(key)
|
getOrCreateUser(key)
|
||||||
} catch (e: IllegalArgumentException) {
|
} catch (e: IllegalArgumentException) {
|
||||||
Log.e("LocalCache", "Invalid Key to create user: $key", e)
|
Log.e("LocalCache", "Invalid Key to create user: $key", e)
|
||||||
@@ -80,7 +80,7 @@ object LocalCache {
|
|||||||
return checkGetOrCreateAddressableNote(key)
|
return checkGetOrCreateAddressableNote(key)
|
||||||
}
|
}
|
||||||
return try {
|
return try {
|
||||||
val checkHex = Hex.decode(key).toNote() // Checks if this is a valid Hex
|
checkIfValidHex(key)
|
||||||
getOrCreateNote(key)
|
getOrCreateNote(key)
|
||||||
} catch (e: IllegalArgumentException) {
|
} catch (e: IllegalArgumentException) {
|
||||||
Log.e("LocalCache", "Invalid Key to create note: $key", e)
|
Log.e("LocalCache", "Invalid Key to create note: $key", e)
|
||||||
@@ -99,7 +99,7 @@ object LocalCache {
|
|||||||
|
|
||||||
fun checkGetOrCreateChannel(key: String): Channel? {
|
fun checkGetOrCreateChannel(key: String): Channel? {
|
||||||
return try {
|
return try {
|
||||||
val checkHex = Hex.decode(key).toNote() // Checks if this is a valid Hex
|
checkIfValidHex(key)
|
||||||
getOrCreateChannel(key)
|
getOrCreateChannel(key)
|
||||||
} catch (e: IllegalArgumentException) {
|
} catch (e: IllegalArgumentException) {
|
||||||
Log.e("LocalCache", "Invalid Key to create channel: $key", e)
|
Log.e("LocalCache", "Invalid Key to create channel: $key", e)
|
||||||
@@ -107,6 +107,10 @@ object LocalCache {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun checkIfValidHex(key: String) {
|
||||||
|
Hex.decode(key).toNpub()
|
||||||
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
fun getOrCreateChannel(key: String): Channel {
|
fun getOrCreateChannel(key: String): Channel {
|
||||||
return channels[key] ?: run {
|
return channels[key] ?: run {
|
||||||
|
Reference in New Issue
Block a user