[F] Fix ghost card handling

This commit is contained in:
Azalea
2025-05-01 13:04:20 -04:00
parent 236266cd7a
commit 1f847439a7
3 changed files with 9 additions and 7 deletions

View File

@@ -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
/**