[O] Make a non-callback version of cardByName

pull/56/head
Azalea 2024-10-03 02:47:20 -04:00
parent ac375abf5e
commit daa5129f65
1 changed files with 5 additions and 4 deletions

View File

@ -130,11 +130,12 @@ class AquaUserServices(
suspend fun <T> byName(username: Str, callback: suspend (AquaNetUser) -> T) =
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()
?.let { cardRepo.findById(it).getOrNull() }
?.let { callback(it) } ?: (404 - "Card not found")
else byName(username) { callback(it.ghostCard) }
?.let { cardRepo.findById(it).getOrNull() } ?: (404 - "Card not found")
else byName(username) { it.ghostCard }
suspend fun <T> cardByName(username: Str, callback: suspend (Card) -> T) = callback(cardByName(username))
fun validKeychip(keychipId: Str): Bool {
if (!allNetProps.checkKeychip) return true