Skip to content

Commit

Permalink
Ensure people can only submit three themes
Browse files Browse the repository at this point in the history
  • Loading branch information
Willdotwhite committed Sep 9, 2024
1 parent f9f24b4 commit b87474c
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import io.ktor.server.auth.*
import io.ktor.server.request.*
import io.ktor.server.response.*
import io.ktor.server.routing.*
import kotlin.math.min

fun Application.configureThemeRouting() {
val authService = AuthService()
Expand All @@ -26,7 +27,7 @@ fun Application.configureThemeRouting() {
post("/themes") {
val auth = getAuthFromCall(authService, call) ?: return@post call.respond(HttpStatusCode.BadRequest)
val data = call.receive<ThemeDTO>()
val themes = data.themes
val themes = data.themes.subList(0, min(data.themes.count(), 3)) // Ensure people can only submit a max of three

themeService.setForUser(auth.discordId, themes)

Expand Down

0 comments on commit b87474c

Please sign in to comment.