Remove Event-related SQL classes and update relevant references across modules

Signed-off-by: Chaoscaot <max@maxsp.de>
This commit is contained in:
2025-10-30 23:14:25 +01:00
parent eea1073892
commit 4e6933f2fd
30 changed files with 679 additions and 797 deletions
@@ -44,11 +44,7 @@ data class ResponseSchematicType(val name: String, val db: String)
@Serializable
data class ResponseUser(val name: String, val uuid: String, val prefix: String, val perms: List<String>) {
constructor(user: SteamwarUser) : this(user.userName, user.uuid.toString(), user.prefix().chatPrefix, user.perms().filter { !it.name.startsWith("PREFIX_") }.map { it.name }) {
synchronized(cache) {
cache[user.getId()] = this
}
}
private constructor(user: SteamwarUser) : this(user.userName, user.uuid.toString(), user.prefix().chatPrefix, user.perms().filter { !it.name.startsWith("PREFIX_") }.map { it.name })
companion object {
private val cache = mutableMapOf<Int, ResponseUser>()
@@ -59,6 +55,10 @@ data class ResponseUser(val name: String, val uuid: String, val prefix: String,
}
}
fun get(user: SteamwarUser): ResponseUser = synchronized(cache) {
return cache[user.getId()] ?: ResponseUser(user).also { cache[user.getId()] = it }
}
fun clearCache() {
synchronized(cache) {
cache.clear()
@@ -75,7 +75,7 @@ fun Route.configureDataRoutes() {
permission = UserPerm.MODERATION
}
get("/users") {
call.respond(SteamwarUser.all().map { ResponseUser(it) })
call.respond(SteamwarUser.all().map { ResponseUser.get(it) })
}
get("/teams") {
call.respond(Team.getAll().map { ResponseTeam(it) })
@@ -118,7 +118,7 @@ fun Route.configureDataRoutes() {
listOf(UserPerm.PREFIX_ADMIN, UserPerm.PREFIX_DEVELOPER, UserPerm.PREFIX_MODERATOR, UserPerm.PREFIX_SUPPORTER, UserPerm.PREFIX_BUILDER)
.associateWith { SteamwarUser.getUsersWithPerm(it) }
.mapKeys { UserPerm.prefixes[it.key]!!.chatPrefix }
.mapValues { it.value.map { ResponseUser(it) } }
.mapValues { it.value.map { ResponseUser.get(it) } }
)
}
get("/skin/{uuid}") {
@@ -137,7 +137,7 @@ fun Route.configureDataRoutes() {
route("/me") {
install(SWPermissionCheck)
get {
call.respond(ResponseUser(call.principal<SWAuthPrincipal>()!!.user))
call.respond(ResponseUser.get(call.principal<SWAuthPrincipal>()!!.user))
}
}
}