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()
|
secret.checkSecret()
|
||||||
|
|
||||||
// 1. Find user card
|
// 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
|
// 2. Change the status to migrated
|
||||||
us.cardRepo.save(oc.apply {
|
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 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()))
|
if (card.status == CardStatus.MIGRATED_TO_MINATO && card.accessTime.plusDays(1).isAfter(utcNow()))
|
||||||
return BotProps.MINATO_CARD_EXT.long
|
return BotProps.MINATO_CARD_EXT.long
|
||||||
|
|
||||||
// Update card access time
|
// Update card access time and return the extId
|
||||||
us.cardRepo.save(card.apply { accessTime = LocalDateTime.now() })
|
us.cardRepo.save(card.apply { accessTime = LocalDateTime.now() }).extId
|
||||||
|
|
||||||
// If it's a ghost card, return the ghost card. Otherwise, return the original card
|
|
||||||
(card.aquaUser?.ghostCard ?: card).extId
|
|
||||||
} ?: -1
|
} ?: -1
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -70,6 +70,11 @@ class Card(
|
|||||||
) {
|
) {
|
||||||
@Suppress("unused") // Used by serialization
|
@Suppress("unused") // Used by serialization
|
||||||
val isLinked get() = aquaUser != null
|
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)
|
fun Card.sensitiveInfo() = mapOf("id" to id, "extId" to extId, "luid" to luid)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user