mirror of https://github.com/hykilpikonna/AquaDX
[+] Wacca username character constraint
parent
de649915e2
commit
646795b753
|
@ -1,13 +1,25 @@
|
|||
package icu.samnyan.aqua.net.games
|
||||
|
||||
import ext.isoDate
|
||||
import ext.minus
|
||||
import java.time.LocalDate
|
||||
|
||||
const val LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
|
||||
"abcdefghijklmnopqrstuvwxyz" +
|
||||
"0123456789"
|
||||
const val SYMBOLS = "・:;?!~/+-×÷=♂♀∀#&*@☆○◎◇□△▽♪†‡ΣαβγθφψωДё$()._␣"
|
||||
const val USERNAME_CHARS = LETTERS + SYMBOLS
|
||||
const val SEGA_USERNAME_CAHRS = LETTERS + SYMBOLS
|
||||
const val WACCA_USERNAME_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
|
||||
"abcdefghijklmnopqrstuvwxyz" +
|
||||
"0123456789" +
|
||||
"~|?!=()[]{},.:;\"@/_-+#*&%$"
|
||||
|
||||
fun usernameCheck(chars: String): (IUserData, String) -> Unit = { u, v ->
|
||||
u.userName = v
|
||||
if (v.isBlank()) { 400 - "Username cannot be blank" }
|
||||
if (v.length > 8) { 400 - "Username too long" }
|
||||
v.find { it !in chars }?.let { 400 - "Invalid character '$it' in username" }
|
||||
}
|
||||
|
||||
data class TrendLog(val date: String, val rating: Int)
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ data class GenericItemMeta(
|
|||
// Here are some interfaces to generalize across multiple games
|
||||
interface IUserData {
|
||||
val id: Long
|
||||
val userName: String
|
||||
var userName: String
|
||||
val playerRating: Int
|
||||
val highestRating: Int
|
||||
val firstPlayDate: Any
|
||||
|
|
|
@ -3,7 +3,6 @@ package icu.samnyan.aqua.net.games.chu3
|
|||
import ext.API
|
||||
import ext.RP
|
||||
import ext.Str
|
||||
import ext.minus
|
||||
import icu.samnyan.aqua.net.db.AquaUserServices
|
||||
import icu.samnyan.aqua.net.games.*
|
||||
import icu.samnyan.aqua.net.utils.*
|
||||
|
@ -24,13 +23,10 @@ class Chusan(
|
|||
.map { TrendLog(it.playDate.toString(), it.playerRating) })
|
||||
}
|
||||
|
||||
|
||||
// Only show > AAA rank
|
||||
override val shownRanks = chu3Scores.filter { it.first >= 95 * 10000 }
|
||||
override val settableFields: Map<String, (Chu3UserData, String) -> Unit> by lazy { mapOf(
|
||||
"userName" to { u, v -> u.setUserName(v)
|
||||
if (!v.all { it in USERNAME_CHARS }) { 400 - "Invalid character in username" }
|
||||
},
|
||||
"userName" to usernameCheck(SEGA_USERNAME_CAHRS)
|
||||
) }
|
||||
|
||||
override suspend fun userSummary(@RP username: Str) = us.cardByName(username) { card ->
|
||||
|
|
|
@ -25,9 +25,7 @@ class Maimai2(
|
|||
// Only show > S rank
|
||||
override val shownRanks = mai2Scores.filter { it.first >= 97 * 10000 }
|
||||
override val settableFields: Map<String, (Mai2UserDetail, String) -> Unit> by lazy { mapOf(
|
||||
"userName" to { u, v -> u.userName = v
|
||||
if (!v.all { it in USERNAME_CHARS }) { 400 - "Invalid character in username" }
|
||||
},
|
||||
"userName" to usernameCheck(SEGA_USERNAME_CAHRS),
|
||||
) }
|
||||
|
||||
override suspend fun userSummary(@RP username: Str) = us.cardByName(username) { card ->
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
package icu.samnyan.aqua.net.games.ongeki
|
||||
|
||||
import ext.API
|
||||
import ext.minus
|
||||
import icu.samnyan.aqua.net.db.AquaUserServices
|
||||
import icu.samnyan.aqua.net.games.GameApiController
|
||||
import icu.samnyan.aqua.net.games.TrendLog
|
||||
import icu.samnyan.aqua.net.games.USERNAME_CHARS
|
||||
import icu.samnyan.aqua.net.games.findTrend
|
||||
import icu.samnyan.aqua.net.games.*
|
||||
import icu.samnyan.aqua.net.utils.*
|
||||
import icu.samnyan.aqua.sega.ongeki.dao.userdata.UserDataRepository
|
||||
import icu.samnyan.aqua.sega.ongeki.dao.userdata.UserGeneralDataRepository
|
||||
|
@ -29,9 +25,7 @@ class Ongeki(
|
|||
|
||||
override val shownRanks = ongekiScores.filter { it.first >= 950000 }
|
||||
override val settableFields: Map<String, (UserData, String) -> Unit> by lazy { mapOf(
|
||||
"userName" to { u, v -> u.setUserName(v)
|
||||
if (!v.all { it in USERNAME_CHARS }) { 400 - "Invalid character in username" }
|
||||
},
|
||||
"userName" to usernameCheck(SEGA_USERNAME_CAHRS)
|
||||
) }
|
||||
|
||||
override suspend fun userSummary(username: String) = us.cardByName(username) { card ->
|
||||
|
|
|
@ -17,9 +17,7 @@ class Wacca(
|
|||
override val userDataRepo: WcUserRepo,
|
||||
): GameApiController<WaccaUser>("wacca", WaccaUser::class) {
|
||||
override val settableFields: Map<String, (WaccaUser, String) -> Unit> by lazy { mapOf(
|
||||
"userName" to { u, v -> u.userName = v
|
||||
if (!v.all { it in USERNAME_CHARS }) { 400 - "Invalid character in username" }
|
||||
},
|
||||
"userName" to usernameCheck(WACCA_USERNAME_CHARS),
|
||||
) }
|
||||
|
||||
override suspend fun trend(@RP username: String) = us.cardByName(username) { card ->
|
||||
|
|
|
@ -4,7 +4,7 @@ import com.fasterxml.jackson.core.JsonProcessingException
|
|||
import ext.invoke
|
||||
import ext.mapApply
|
||||
import ext.minus
|
||||
import icu.samnyan.aqua.net.games.USERNAME_CHARS
|
||||
import icu.samnyan.aqua.net.games.SEGA_USERNAME_CAHRS
|
||||
import icu.samnyan.aqua.sega.general.BaseHandler
|
||||
import icu.samnyan.aqua.sega.general.service.CardService
|
||||
import icu.samnyan.aqua.sega.maimai2.handler.UploadUserPlaylogHandler.Companion.playBacklog
|
||||
|
@ -27,7 +27,7 @@ class UpsertUserAllHandler(
|
|||
val repos: Mai2Repos
|
||||
) : BaseHandler {
|
||||
|
||||
fun String.isValidUsername() = isNotBlank() && length <= 8 && all { it in USERNAME_CHARS }
|
||||
fun String.isValidUsername() = isNotBlank() && length <= 8 && all { it in SEGA_USERNAME_CAHRS }
|
||||
|
||||
@Throws(JsonProcessingException::class)
|
||||
override fun handle(request: Map<String, Any>): Any? {
|
||||
|
|
Loading…
Reference in New Issue