Improved ban detection
This commit is contained in:
parent
6a1f3ab3b1
commit
64f3960a1d
@ -103,7 +103,18 @@ class ImportUsers(
|
||||
|
||||
val isUserBanned = this.osuApi.checkIfUserBanned(missingId)
|
||||
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.messagingTemplate.convertAndSend("/topic/banlist", missingId)
|
||||
dslContext.update(SCORES)
|
||||
@ -116,6 +127,20 @@ class ImportUsers(
|
||||
.where(USERS.USER_ID.eq(missingId))
|
||||
.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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user