Skip to content
This repository was archived by the owner on Dec 10, 2025. It is now read-only.

Commit 1cd82f9

Browse files
committed
chore: Remove dead code and add todos at places where things have to be fixed
1 parent 4349257 commit 1cd82f9

17 files changed

+108
-461
lines changed

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gradle/libs.versions.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ ktor-server-resources = { module = "io.ktor:ktor-server-resources" }
5151
kotlin-css = { module = "org.jetbrains.kotlin-wrappers:kotlin-css" }
5252
ktor-server-websockets = { module = "io.ktor:ktor-server-websockets" }
5353
ktor-serialization-kotlinx-json = { module = "io.ktor:ktor-serialization-kotlinx-json" }
54+
ktor-content-negotiation = { module = "io.ktor:ktor-server-content-negotiation" }
5455
ktor-server-auth = { module = "io.ktor:ktor-server-auth" }
5556
bson-kotlinx = { module = "org.mongodb:bson-kotlinx", version.ref = "bson-kotlinx" }
5657
aspectjweaver = { module = "org.aspectj:aspectjweaver" }
@@ -84,5 +85,5 @@ jackson-api-common = ["jackson-core", "jackson-databind", "jackson-module-kotlin
8485
exposed-api-server = ["exposed-spring-boot-starter", "exposed-java-time", "exposed-migration"]
8586
maven-libraries = ["maven-impl", "maven-resolver"]
8687
console-api = ["jline", "brigadier", "terminalconsoleappender"]
87-
ktor-api-server = ["ktor-server-core-jvm", "ktor-server-netty", "ktor-server-core", "ktor-server-html-builder", "kotlin-css", "ktor-server-websockets", "ktor-serialization-kotlinx-json", "ktor-server-resources", "ktor-server-auth"]
88+
ktor-api-server = ["ktor-server-core-jvm", "ktor-server-netty", "ktor-server-core", "ktor-server-html-builder", "kotlin-css", "ktor-server-websockets", "ktor-content-negotiation", "ktor-serialization-kotlinx-json", "ktor-server-resources", "ktor-server-auth"]
8889
flyway = ["flyway-core", "flyway-mysql"]

surf-cloud-standalone/build.gradle.kts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ val sanitizeLibs by tasks.registering {
3333
inJar.copyTo(dest, overwrite = true)
3434
} else {
3535
// entpacken -> problematische Einträge ausschließen -> wieder zippen
36-
val tmp = layout.buildDirectory.dir("tmp/sanitize/${inJar.nameWithoutExtension}").get().asFile
36+
val tmp = layout.buildDirectory.dir("tmp/sanitize/${inJar.nameWithoutExtension}")
37+
.get().asFile
3738
tmp.deleteRecursively(); tmp.mkdirs()
3839

3940
copy {
@@ -44,7 +45,10 @@ val sanitizeLibs by tasks.registering {
4445
)
4546
into(tmp)
4647
}
47-
ant.invokeMethod("zip", mapOf("basedir" to tmp.absolutePath, "destfile" to dest.absolutePath))
48+
ant.invokeMethod(
49+
"zip",
50+
mapOf("basedir" to tmp.absolutePath, "destfile" to dest.absolutePath)
51+
)
4852
}
4953
}
5054
}

surf-cloud-standalone/src/main/kotlin/dev/slne/surf/cloud/standalone/GenerateExposedMigrationScript.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package dev.slne.surf.cloud.standalone
22

33
import dev.slne.surf.cloud.api.server.exposed.migration.generateSimpleExposedMigration
4+
import dev.slne.surf.cloud.standalone.player.db.exposed.CloudPlayerNameHistoryTable
5+
import dev.slne.surf.cloud.standalone.player.db.exposed.CloudPlayerPlaytimesTable
46
import dev.slne.surf.cloud.standalone.player.db.exposed.punishment.table.*
57
import dev.slne.surf.cloud.standalone.player.db.exposed.whitelist.WhitelistTable
68

@@ -16,6 +18,8 @@ fun main() {
1618
MutePunishmentNoteTable,
1719
WarnPunishmentNoteTable,
1820
WhitelistTable,
19-
scriptName = "V8__rename_tables_and_use_cloud_player_references",
21+
CloudPlayerNameHistoryTable,
22+
CloudPlayerPlaytimesTable,
23+
scriptName = "V1__create_tables",
2024
)
2125
}

surf-cloud-standalone/src/main/kotlin/dev/slne/surf/cloud/standalone/ktor/KtorServer.kt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,24 @@ import dev.slne.surf.cloud.core.common.spring.CloudLifecycleAware
88
import dev.slne.surf.cloud.standalone.config.StandaloneConfigHolder
99
import dev.slne.surf.cloud.standalone.ktor.routes.punish.punishRoutes
1010
import io.ktor.http.*
11+
import io.ktor.serialization.kotlinx.json.*
1112
import io.ktor.server.application.*
1213
import io.ktor.server.auth.*
1314
import io.ktor.server.engine.*
1415
import io.ktor.server.html.*
1516
import io.ktor.server.netty.*
1617
import io.ktor.server.plugins.*
18+
import io.ktor.server.plugins.ContentTransformationException
19+
import io.ktor.server.plugins.contentnegotiation.*
1720
import io.ktor.server.plugins.statuspages.*
21+
import io.ktor.server.request.*
1822
import io.ktor.server.resources.*
23+
import io.ktor.server.response.*
1924
import io.ktor.server.routing.*
2025
import kotlinx.coroutines.launch
2126
import kotlinx.html.*
27+
import kotlinx.serialization.Serializable
28+
import kotlinx.serialization.json.Json
2229
import org.springframework.core.annotation.Order
2330
import org.springframework.stereotype.Component
2431
import java.security.MessageDigest
@@ -50,6 +57,12 @@ class KtorServer(private val configHolder: StandaloneConfigHolder) : CloudLifecy
5057
// pingPeriod = 15.seconds
5158
// }
5259
install(Resources)
60+
install(ContentNegotiation) {
61+
json(Json {
62+
isLenient = true
63+
ignoreUnknownKeys = true
64+
})
65+
}
5366
authentication {
5467
bearer {
5568
realm = "Access to the '/' path"
@@ -78,11 +91,24 @@ class KtorServer(private val configHolder: StandaloneConfigHolder) : CloudLifecy
7891
}
7992
punishRoutes()
8093
}
94+
95+
trace {
96+
println(it.buildText())
97+
}
98+
99+
post("/test") {
100+
val testData = call.receive<TestData>()
101+
println("Received test data: ${testData.name}")
102+
call.respondText("Test data received successfully.", status = HttpStatusCode.OK)
103+
}
81104
}
82105
}
83106
server.start(wait = true)
84107
}
85108

109+
@Serializable
110+
data class TestData(val name: String)
111+
86112
private fun StatusPagesConfig.configure() {
87113
status(HttpStatusCode.NotFound) { call, _ ->
88114
call.respondErrorPage(

surf-cloud-standalone/src/main/kotlin/dev/slne/surf/cloud/standalone/ktor/routes/punish/create/CreatePunishRoute.kt

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,30 @@ import dev.slne.surf.cloud.standalone.ktor.routes.punish.create.ban.CreateBanPun
66
import dev.slne.surf.cloud.standalone.ktor.routes.punish.create.kick.CreateKickPunishmentRoute
77
import dev.slne.surf.cloud.standalone.ktor.routes.punish.create.mute.CreateMutePunishmentRoute
88
import dev.slne.surf.cloud.standalone.ktor.routes.punish.create.warn.CreateWarnPunishmentRoute
9+
import dev.slne.surf.surfapi.core.api.util.logger
910
import io.ktor.http.*
11+
import io.ktor.server.request.*
1012
import io.ktor.server.response.*
1113
import io.ktor.server.routing.*
1214

13-
fun Routing.createPunishRoutes() = route("/create") {
15+
fun Route.createPunishRoutes() = route("/create") {
1416
post<CreateBanPunishmentRoute> { banMeta ->
1517
bean<PunishmentManager>().broadcastBan(banMeta.toApiObject())
1618
call.respond(HttpStatusCode.OK, "Ban punishment broadcasted successfully.")
1719
}
1820

19-
post<CreateKickPunishmentRoute> { kickMeta ->
21+
get("/kick") {
22+
logger().atInfo().log("Received GET request for kick punishment creation.")
23+
call.respond(
24+
HttpStatusCode.MethodNotAllowed,
25+
"GET method is not allowed for kick punishment creation. Use POST instead."
26+
)
27+
}
28+
29+
post("/kick") {
30+
val kickMeta = call.receive<CreateKickPunishmentRoute>()
31+
32+
logger().atInfo().log("Broadcasting kick punishment: $kickMeta")
2033
bean<PunishmentManager>().broadcastKick(kickMeta.toApiObject())
2134
call.respond(HttpStatusCode.OK, "Kick punishment broadcasted successfully.")
2235
}

surf-cloud-standalone/src/main/kotlin/dev/slne/surf/cloud/standalone/ktor/routes/punish/create/kick/CreateKickPunishmentRoute.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ package dev.slne.surf.cloud.standalone.ktor.routes.punish.create.kick
33
import dev.slne.surf.cloud.core.common.player.punishment.type.PunishmentKickImpl
44
import dev.slne.surf.cloud.standalone.ktor.types.ZonedDateTimeAsString
55
import dev.slne.surf.surfapi.core.api.service.UUIDAsString
6-
import io.ktor.resources.*
6+
import kotlinx.serialization.Serializable
77

8-
@Resource("/kick")
8+
//@Resource("/kick")
9+
@Serializable
910
class CreateKickPunishmentRoute(
1011
val id: Long,
1112
val punishmentId: String,

surf-cloud-standalone/src/main/kotlin/dev/slne/surf/cloud/standalone/player/db/exposed/punishment/table/AbstractUnpunishableExpirablePunishmentTable.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ abstract class AbstractUnpunishableExpirablePunishmentTable(name: String) :
1919
val permanent = bool("permanent").default(false)
2020

2121
init {
22-
index("idx_punished_uuid_unpunished", false, punishedPlayerId, unpunished)
2322
index("idx_permanent_exp", false, permanent, expirationDate)
2423
}
2524
}

surf-cloud-standalone/src/main/resources/db/migration/V1__Add_cloud_player_tables.sql

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)