Improved ban detection

This commit is contained in:
nise.moe 2024-06-12 12:55:06 +02:00
parent 6a1f3ab3b1
commit 64f3960a1d

View File

@ -103,7 +103,18 @@ class ImportUsers(
val isUserBanned = this.osuApi.checkIfUserBanned(missingId) val isUserBanned = this.osuApi.checkIfUserBanned(missingId)
Thread.sleep(SLEEP_AFTER_API_CALL) Thread.sleep(SLEEP_AFTER_API_CALL)
if (isUserBanned == true) {
if(isUserBanned == null) {
this.logger.error("Failed to check if user $missingId is banned")
continue
}
// If the user IS indeed banned, we update the user's status in the database if needed.
val isUserAlreadyBanned = dslContext.selectFrom(USERS)
.where(USERS.USER_ID.eq(missingId))
.fetchOne(USERS.IS_BANNED) ?: false
if(isUserBanned && !isUserAlreadyBanned) {
this.logger.warn("User $missingId is banned") this.logger.warn("User $missingId is banned")
this.messagingTemplate.convertAndSend("/topic/banlist", missingId) this.messagingTemplate.convertAndSend("/topic/banlist", missingId)
dslContext.update(SCORES) dslContext.update(SCORES)
@ -116,6 +127,20 @@ class ImportUsers(
.where(USERS.USER_ID.eq(missingId)) .where(USERS.USER_ID.eq(missingId))
.execute() .execute()
} }
if(!isUserBanned) {
this.logger.info("User $missingId is not banned")
dslContext.update(USERS)
.set(USERS.IS_BANNED, false)
.where(USERS.USER_ID.eq(missingId))
.execute()
dslContext.update(SCORES)
.set(SCORES.IS_BANNED, false)
.where(SCORES.USER_ID.eq(missingId))
.execute()
}
} }
// Update the rest of the users // Update the rest of the users