[F] Fix SDGA 1.65 / SDGB 1.53 playlog, add nonce to UpsertUserAll (#238)

This commit is contained in:
Azalea
2026-08-06 04:44:41 +08:00
committed by GitHub
parent 3be81520ce
commit 5e6aaace8c
2 changed files with 19 additions and 2 deletions
@@ -28,12 +28,22 @@ class UpsertUserAllHandler(
) : BaseHandler {
fun String.isValidUsername() = isNotBlank() && length <= 8
// For preventing duplicates: {nonce: processed time}
val processed = mutableMapOf<Pair<Long, Long>, Long>()
fun cleanupProcessed() = processed.entries.removeIf { System.currentTimeMillis() - it.value > 5 * 60 * 1000 }
@Throws(JacksonException::class)
override fun handle(request: Map<String, Any>): Any? {
val upsertUserAll = mapper.convert(request, Mai2UpsertUserAll::class.java)
val userId = upsertUserAll.userId
val req = upsertUserAll.upsertUserAll
// Check if the request has been processed before
val nonce = Pair(userId, upsertUserAll.loginDateTime)
if (processed.containsKey(nonce)) return SUCCESS
processed[nonce] = System.currentTimeMillis()
cleanupProcessed()
// If user is guest, just return OK response.
if ((userId and 281474976710657L) == 281474976710657L) return SUCCESS
@@ -75,7 +85,7 @@ class UpsertUserAllHandler(
listOfNotNull(
userExtend, userOption, userCharacterList, userMapList, userLoginBonusList, userItemList,
userMusicDetailList, userCourseList, userFriendSeasonRankingList, userFavoriteList,
userKaleidxScopeList, userIntimateList
userKaleidxScopeList, userIntimateList, upsertUserAll.userPlaylogList
)
}.flatten().forEach { it.user = u }
@@ -142,6 +152,9 @@ class UpsertUserAllHandler(
repos.userIntimate.saveAll(lst.mapApply {
id = repos.userIntimate.findByUserAndPartnerId(u, partnerId)?.id ?: 0 }) }
// Added on SDGA 1.65 / SDGB 1.53
upsertUserAll.userPlaylogList?.let(repos.userPlaylog::saveAll)
// 2024/10/31 Found some user data findByUserAndKindAndActivityId is not unique
// I think userActivityList is not important, so I will ignore it
try {
@@ -5,7 +5,11 @@ import icu.samnyan.aqua.sega.maimai2.model.userdata.*
class Mai2UpsertUserAll(
var userId: Long,
var upsertUserAll: Mai2UserAll
var upsertUserAll: Mai2UserAll,
var loginDateTime: Long = 0, // Nonce, sort of
var userPlaylogList: List<Mai2UserPlaylog>? = null, // SDGA 1.65 / SDGB 1.53
)
class Mai2UserAll {