mirror of https://github.com/hykilpikonna/AquaDX
[O] Make a non-callback version of cardByName
parent
ac375abf5e
commit
daa5129f65
|
@ -130,11 +130,12 @@ class AquaUserServices(
|
||||||
suspend fun <T> byName(username: Str, callback: suspend (AquaNetUser) -> T) =
|
suspend fun <T> byName(username: Str, callback: suspend (AquaNetUser) -> T) =
|
||||||
async { userRepo.findByUsernameIgnoreCase(username) }?.let { callback(it) } ?: (404 - "User not found")
|
async { userRepo.findByUsernameIgnoreCase(username) }?.let { callback(it) } ?: (404 - "User not found")
|
||||||
|
|
||||||
suspend fun <T> cardByName(username: Str, callback: suspend (Card) -> T) =
|
suspend fun cardByName(username: Str) =
|
||||||
if (username.startsWith("user")) username.substring(4).toLongOrNull()
|
if (username.startsWith("user")) username.substring(4).toLongOrNull()
|
||||||
?.let { cardRepo.findById(it).getOrNull() }
|
?.let { cardRepo.findById(it).getOrNull() } ?: (404 - "Card not found")
|
||||||
?.let { callback(it) } ?: (404 - "Card not found")
|
else byName(username) { it.ghostCard }
|
||||||
else byName(username) { callback(it.ghostCard) }
|
|
||||||
|
suspend fun <T> cardByName(username: Str, callback: suspend (Card) -> T) = callback(cardByName(username))
|
||||||
|
|
||||||
fun validKeychip(keychipId: Str): Bool {
|
fun validKeychip(keychipId: Str): Bool {
|
||||||
if (!allNetProps.checkKeychip) return true
|
if (!allNetProps.checkKeychip) return true
|
||||||
|
|
Loading…
Reference in New Issue