Forces valid hexes for users and notes

pull/586/head
Vitor Pamplona 2023-09-09 14:39:41 -04:00
rodzic cda821e5af
commit 8518819dfa
1 zmienionych plików z 7 dodań i 1 usunięć

Wyświetl plik

@ -53,6 +53,10 @@ object LocalCache {
// checkNotInMainThread()
return users[key] ?: run {
require(isValidHex(key = key)) {
"$key is not a valid hex"
}
val newObject = User(key)
users.putIfAbsent(key, newObject) ?: newObject
}
@ -98,7 +102,9 @@ object LocalCache {
checkNotInMainThread()
return notes.get(idHex) ?: run {
require(isValidHex(idHex))
require(isValidHex(idHex)) {
"$idHex is not a valid hex"
}
val newObject = Note(idHex)
notes.putIfAbsent(idHex, newObject) ?: newObject