mirror of https://github.com/hykilpikonna/AquaDX
[+] API for bot to ban user from ranking board
parent
17a0209c8c
commit
7ee4c14fae
|
@ -133,5 +133,9 @@ server.error.whitelabel.enabled=false
|
|||
aqua-net.frontier.enabled=false
|
||||
aqua-net.frontier.ftk=0x00
|
||||
|
||||
## APIs for bot management
|
||||
aqua-net.bot.enabled=true
|
||||
aqua-net.bot.secret=hunter2
|
||||
|
||||
## OpenAI Settings (For content moderation)
|
||||
aqua-net.openai.api-key=sk-1234567890abcdef1234567890abcdef
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
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 org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties
|
||||
import org.springframework.context.annotation.Configuration
|
||||
import org.springframework.web.bind.annotation.PostMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "aqua-net.bot")
|
||||
class BotProps {
|
||||
var enabled: Boolean = false
|
||||
var secret: String = ""
|
||||
}
|
||||
|
||||
@RestController
|
||||
@ConditionalOnProperty("aqua-net.frontier.enabled", havingValue = "true")
|
||||
@API("/api/v2/bot")
|
||||
class BotController(
|
||||
val cardService: CardService,
|
||||
val us: AquaUserServices,
|
||||
val props: BotProps
|
||||
) {
|
||||
fun Str.checkSecret() {
|
||||
if (this != props.secret) 403 - "Invalid Secret"
|
||||
}
|
||||
|
||||
@PostMapping("/ranking-ban")
|
||||
@Doc("Register a new card by access code", "Card information")
|
||||
suspend fun rankingBan(@RP secret: Str, @RP username: Str) {
|
||||
secret.checkSecret()
|
||||
|
||||
us.cardByName(username) { card ->
|
||||
card.rankingBanned = true
|
||||
cardService.cardRepo.save(card)
|
||||
|
||||
SUCCESS
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue