forked from Cookies_Public/AquaDX
[F] Fix ghost card handling
This commit is contained in:
parent
236266cd7a
commit
1f847439a7
@ -56,7 +56,7 @@ class BotController(
|
||||
secret.checkSecret()
|
||||
|
||||
// 1. Find user card
|
||||
val oc = us.cardRepo.findByLuid(card)() ?: (404 - "Card not found")
|
||||
val oc = (us.cardRepo.findByLuid(card)() ?: (404 - "Card not found")).maybeGhost()
|
||||
|
||||
// 2. Change the status to migrated
|
||||
us.cardRepo.save(oc.apply {
|
||||
|
||||
@ -124,16 +124,13 @@ class AimeDB(
|
||||
}
|
||||
}
|
||||
|
||||
fun getCard(accessCode: String) = us.cardRepo.findByLuid(accessCode)()?.let { card ->
|
||||
fun getCard(accessCode: String) = us.cardRepo.findByLuid(accessCode)()?.maybeGhost()?.let { card ->
|
||||
// If it's migrated to Minato, return the Minato card for 24 hours
|
||||
if (card.status == CardStatus.MIGRATED_TO_MINATO && card.accessTime.plusDays(1).isAfter(utcNow()))
|
||||
return BotProps.MINATO_CARD_EXT.long
|
||||
|
||||
// Update card access time
|
||||
us.cardRepo.save(card.apply { accessTime = LocalDateTime.now() })
|
||||
|
||||
// If it's a ghost card, return the ghost card. Otherwise, return the original card
|
||||
(card.aquaUser?.ghostCard ?: card).extId
|
||||
// Update card access time and return the extId
|
||||
us.cardRepo.save(card.apply { accessTime = LocalDateTime.now() }).extId
|
||||
} ?: -1
|
||||
|
||||
/**
|
||||
|
||||
@ -70,6 +70,11 @@ class Card(
|
||||
) {
|
||||
@Suppress("unused") // Used by serialization
|
||||
val isLinked get() = aquaUser != null
|
||||
|
||||
/**
|
||||
* Returns ghost card if this card is a ghost card, otherwise returns this card
|
||||
*/
|
||||
fun maybeGhost() = aquaUser?.ghostCard ?: this
|
||||
}
|
||||
|
||||
fun Card.sensitiveInfo() = mapOf("id" to id, "extId" to extId, "luid" to luid)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user