forked from Cookies_Github_mirror/AquaDX
Merge branch 'v1-dev' into matching
This commit is contained in:
@@ -21,7 +21,6 @@ import java.security.MessageDigest
|
||||
import java.time.LocalDate
|
||||
import java.time.LocalDateTime
|
||||
import java.time.ZoneId
|
||||
import java.time.ZonedDateTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
import java.util.*
|
||||
import java.util.concurrent.locks.Lock
|
||||
|
||||
@@ -3,7 +3,10 @@ package icu.samnyan.aqua.net
|
||||
import ext.*
|
||||
import icu.samnyan.aqua.net.db.AquaUserServices
|
||||
import icu.samnyan.aqua.net.utils.SUCCESS
|
||||
import icu.samnyan.aqua.sega.general.service.CardService
|
||||
import icu.samnyan.aqua.sega.chusan.model.Chu3Repos
|
||||
import icu.samnyan.aqua.sega.general.model.sensitiveInfo
|
||||
import icu.samnyan.aqua.sega.maimai2.model.Mai2Repos
|
||||
import jakarta.transaction.Transactional
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties
|
||||
import org.springframework.context.annotation.Configuration
|
||||
@@ -18,12 +21,13 @@ class BotProps {
|
||||
}
|
||||
|
||||
@RestController
|
||||
@ConditionalOnProperty("aqua-net.frontier.enabled", havingValue = "true")
|
||||
@ConditionalOnProperty("aqua-net.bot.enabled", havingValue = "true")
|
||||
@API("/api/v2/bot")
|
||||
class BotController(
|
||||
val cardService: CardService,
|
||||
val us: AquaUserServices,
|
||||
val props: BotProps
|
||||
val props: BotProps,
|
||||
val chu3Db: Chu3Repos,
|
||||
val mai2Db: Mai2Repos,
|
||||
) {
|
||||
fun Str.checkSecret() {
|
||||
if (this != props.secret) 403 - "Invalid Secret"
|
||||
@@ -31,14 +35,55 @@ class BotController(
|
||||
|
||||
@PostMapping("/ranking-ban")
|
||||
@Doc("Ban a user from the leaderboard", "Success status")
|
||||
suspend fun rankingBan(@RP secret: Str, @RP username: Str) {
|
||||
suspend fun rankingBan(@RP secret: Str, @RP username: Str): Any {
|
||||
secret.checkSecret()
|
||||
|
||||
us.cardByName(username) { card ->
|
||||
return us.cardByName(username) { card ->
|
||||
card.rankingBanned = true
|
||||
cardService.cardRepo.save(card)
|
||||
us.cardRepo.save(card)
|
||||
|
||||
SUCCESS
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@PostMapping("/debug-user-profile")
|
||||
@Doc("Obtain debug information for a user card", "User card details")
|
||||
fun debugUserProfile(@RP secret: Str, @RP cardId: Str): Any {
|
||||
secret.checkSecret()
|
||||
|
||||
// 1. Check if the card exist
|
||||
var cards = listOfNotNull(
|
||||
us.cardRepo.findByExtId(cardId.long)(),
|
||||
us.cardRepo.findByLuid(cardId)(),
|
||||
us.cardRepo.findById(cardId.long)(),
|
||||
).toMutableList()
|
||||
cards += cards.flatMap {
|
||||
(it.aquaUser?.cards ?: emptyList()) + listOfNotNull(it.aquaUser?.ghostCard)
|
||||
}
|
||||
cards = cards.distinctBy { it.id }.toMutableList()
|
||||
|
||||
return cards.map { card ->
|
||||
// Find all games played by this card
|
||||
val chu3 = chu3Db.userData.findByCard_ExtId(card.extId)()
|
||||
val mai2 = mai2Db.userData.findByCard_ExtId(card.extId)()
|
||||
val gamesDict = listOfNotNull(chu3, mai2).map {
|
||||
// Find the keychip owner
|
||||
val keychip = it.lastClientId
|
||||
val keychipOwner = keychip?.let { us.userRepo.findByKeychip(it) }
|
||||
|
||||
mapOf(
|
||||
"userData" to it,
|
||||
"keychip" to keychip,
|
||||
"keychipOwner" to keychipOwner,
|
||||
"keychipOwnerCards" to keychipOwner?.cards?.map { it.sensitiveInfo() }
|
||||
)
|
||||
}
|
||||
|
||||
mapOf(
|
||||
"card" to card.sensitiveInfo(),
|
||||
"games" to gamesDict
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,8 +32,11 @@ class AquaGameOptions(
|
||||
@SettingField("wacca")
|
||||
var waccaAlwaysVip: Boolean = false,
|
||||
|
||||
@SettingField("general")
|
||||
@SettingField("chu3")
|
||||
var chusanTeamName: String = "",
|
||||
|
||||
@SettingField("chu3")
|
||||
var chusanInfinitePenguins: Boolean = false,
|
||||
)
|
||||
|
||||
interface AquaGameOptionsRepo : JpaRepository<AquaGameOptions, Long>
|
||||
|
||||
@@ -30,15 +30,13 @@ class Chusan(
|
||||
"trophyId" to { u, v -> u.trophyId = v.int },
|
||||
"mapIconId" to { u, v -> u.mapIconId = v.int },
|
||||
"voiceId" to { u, v -> u.voiceId = v.int },
|
||||
"avatarItem" to { u, v -> v.split(':', limit=2).map { it.int }.let { (cat, data) -> when (cat) {
|
||||
1 -> u.avatarWear = data
|
||||
2 -> u.avatarHead = data
|
||||
3 -> u.avatarFace = data
|
||||
4 -> u.avatarSkin = data
|
||||
5 -> u.avatarItem = data
|
||||
6 -> u.avatarFront = data
|
||||
7 -> u.avatarBack = data
|
||||
} } }
|
||||
"avatarWear" to { u, v -> u.avatarWear = v.int },
|
||||
"avatarHead" to { u, v -> u.avatarHead = v.int },
|
||||
"avatarFace" to { u, v -> u.avatarFace = v.int },
|
||||
"avatarSkin" to { u, v -> u.avatarSkin = v.int },
|
||||
"avatarItem" to { u, v -> u.avatarItem = v.int },
|
||||
"avatarFront" to { u, v -> u.avatarFront = v.int },
|
||||
"avatarBack" to { u, v -> u.avatarBack = v.int },
|
||||
) }
|
||||
|
||||
override suspend fun userSummary(@RP username: Str, @RP token: String?) = us.cardByName(username) { card ->
|
||||
@@ -60,11 +58,9 @@ class Chusan(
|
||||
// UserBox related APIs
|
||||
@API("user-box")
|
||||
fun userBox(@RP token: String) = us.jwt.auth(token) {
|
||||
userDataRepo.findByCard(it.ghostCard) ?: (404 - "Game data not found") }
|
||||
|
||||
@API("user-box-item-by-kind")
|
||||
fun userBoxItem(@RP token: String, @RP itemId: Int) = us.jwt.auth(token) {
|
||||
rp.userItem.findAllByUser_Card_ExtIdAndItemKind(it.ghostCard.extId, itemId) }
|
||||
val u = userDataRepo.findByCard(it.ghostCard) ?: (404 - "Game data not found")
|
||||
mapOf("user" to u, "items" to rp.userItem.findAllByUser(u))
|
||||
}
|
||||
|
||||
@API("user-box-all-items")
|
||||
fun userBoxAllItems() = allItems
|
||||
|
||||
@@ -6,6 +6,7 @@ import icu.samnyan.aqua.sega.chusan.model.response.data.MatchingMemberInfo
|
||||
import icu.samnyan.aqua.sega.chusan.model.response.data.MatchingWaitState
|
||||
import icu.samnyan.aqua.sega.chusan.model.response.data.UserEmoney
|
||||
import icu.samnyan.aqua.sega.chusan.model.userdata.UserCharge
|
||||
import icu.samnyan.aqua.sega.chusan.model.userdata.UserItem
|
||||
import icu.samnyan.aqua.sega.chusan.model.userdata.UserMusicDetail
|
||||
import icu.samnyan.aqua.sega.general.model.response.UserRecentRating
|
||||
import java.time.format.DateTimeFormatter
|
||||
@@ -122,13 +123,26 @@ val chusanInit: ChusanController.() -> Unit = {
|
||||
}
|
||||
}
|
||||
|
||||
// Check dev/chusan_dev_notes for more item information
|
||||
val penguins = ls(8000, 8010, 8020, 8030)
|
||||
|
||||
"GetUserItem".pagedWithKind("userItemList") {
|
||||
val rawIndex = data["nextIndex"]!!.long
|
||||
val kind = parsing { (rawIndex / 10000000000L).int }
|
||||
data["nextIndex"] = rawIndex % 10000000000L
|
||||
mapOf("itemKind" to kind) grabs {
|
||||
// TODO: All unlock
|
||||
db.userItem.findAllByUser_Card_ExtIdAndItemKind(uid, kind)
|
||||
val items = db.userItem.findAllByUser_Card_ExtIdAndItemKind(uid, kind).toMutableList()
|
||||
|
||||
// Check game options
|
||||
db.userData.findByCard_ExtId(uid)()?.card?.aquaUser?.gameOptions?.let {
|
||||
if (it.chusanInfinitePenguins && kind == 5) {
|
||||
items.removeAll { it.itemId in penguins }
|
||||
items.addAll(penguins.map { UserItem(kind, it, 999, true) })
|
||||
}
|
||||
}
|
||||
|
||||
items
|
||||
} postProcess {
|
||||
val ni = it["nextIndex"]!!.long
|
||||
if (ni != -1L) it["nextIndex"] = ni + (kind * 10000000000L)
|
||||
|
||||
@@ -90,6 +90,7 @@ interface Chu3UserGeneralDataRepo : Chu3UserLinked<UserGeneralData> {
|
||||
}
|
||||
|
||||
interface Chu3UserItemRepo : Chu3UserLinked<UserItem> {
|
||||
fun findAllByUser(user: Chu3UserData): List<UserItem>
|
||||
fun findTopByUserAndItemIdAndItemKindOrderByIdDesc(user: Chu3UserData, itemId: Int, itemKind: Int): Optional<UserItem>
|
||||
fun findByUserAndItemIdAndItemKind(user: Chu3UserData, itemId: Int, itemKind: Int): UserItem?
|
||||
|
||||
|
||||
@@ -48,3 +48,5 @@ class Card(
|
||||
@Suppress("unused") // Used by serialization
|
||||
val isLinked get() = aquaUser != null
|
||||
}
|
||||
|
||||
fun Card.sensitiveInfo() = mapOf("id" to id, "extId" to extId, "luid" to luid)
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
ALTER TABLE aqua_game_options ADD chusan_infinite_penguins BIT(1) NOT NULL DEFAULT 0;
|
||||
Reference in New Issue
Block a user