Adapt
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
Chaoscaot 2024-08-15 16:40:25 +02:00
Ursprung 932ad60f0b
Commit 3d287215e2
2 geänderte Dateien mit 10 neuen und 14 gelöschten Zeilen

Datei anzeigen

@ -56,12 +56,7 @@ data class ResponseUser(val id: Int, val name: String, val uuid: String, val pre
fun get(id: Int): ResponseUser {
synchronized(cache) {
if(cache.containsKey(id)) {
return cache[id]!!
}
val user = ResponseUser(SteamwarUser.get(id))
cache[id] = user
return user
return cache[id] ?: ResponseUser(SteamwarUser.get(id)).also { cache[id] = it }
}
}
@ -109,6 +104,7 @@ fun Route.configureDataRoutes() {
call.respond(
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) } }
)
}

Datei anzeigen

@ -88,7 +88,7 @@ data class PageResponse(
}
@Serializable
data class CreatePageRequest(val path: String)
data class CreatePageRequest(val path: String, val slug: String?, val title: String?)
@Serializable
data class CreateBranchRequest(val branch: String)
@ -177,23 +177,23 @@ fun Route.configurePage() {
@Serializable
data class CreateGiteaPageRequest(val message: String, val content: String, val branch: String, val author: Identity)
val path = call.receive<CreatePageRequest>().path
if(path.startsWith("src/content/")) {
val req = call.receive<CreatePageRequest>()
if(req.path.startsWith("src/content/")) {
call.respond(HttpStatusCode.BadRequest, "Invalid path")
return@post
}
val res = client.post("repos/SteamWar/Website/contents/src/content/$path") {
val res = client.post("repos/SteamWar/Website/contents/src/content/${req.path}") {
contentType(ContentType.Application.Json)
setBody(CreateGiteaPageRequest(
"Create page $path",
"Create page ${req.path}",
Base64.getEncoder().encodeToString("""
---
title: [Enter Title]
title: ${req.title ?: "[Enter Title]"}
description: [Enter Description]
slug: [Enter Slug]
slug: ${req.slug ?: "[Enter Slug]"}
---
# $path
# ${req.path}
""".trimIndent().toByteArray()),
call.request.queryParameters["branch"] ?: "master",
Identity(call.principal<SWAuthPrincipal>()!!.user.userName, "admin-tool@steamwar.de"