Ursprung
932ad60f0b
Commit
3d287215e2
@ -56,12 +56,7 @@ data class ResponseUser(val id: Int, val name: String, val uuid: String, val pre
|
|||||||
|
|
||||||
fun get(id: Int): ResponseUser {
|
fun get(id: Int): ResponseUser {
|
||||||
synchronized(cache) {
|
synchronized(cache) {
|
||||||
if(cache.containsKey(id)) {
|
return cache[id] ?: ResponseUser(SteamwarUser.get(id)).also { cache[id] = it }
|
||||||
return cache[id]!!
|
|
||||||
}
|
|
||||||
val user = ResponseUser(SteamwarUser.get(id))
|
|
||||||
cache[id] = user
|
|
||||||
return user
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,6 +104,7 @@ fun Route.configureDataRoutes() {
|
|||||||
call.respond(
|
call.respond(
|
||||||
listOf(UserPerm.PREFIX_ADMIN, UserPerm.PREFIX_DEVELOPER, UserPerm.PREFIX_MODERATOR, UserPerm.PREFIX_SUPPORTER, UserPerm.PREFIX_BUILDER)
|
listOf(UserPerm.PREFIX_ADMIN, UserPerm.PREFIX_DEVELOPER, UserPerm.PREFIX_MODERATOR, UserPerm.PREFIX_SUPPORTER, UserPerm.PREFIX_BUILDER)
|
||||||
.associateWith { SteamwarUser.getUsersWithPerm(it) }
|
.associateWith { SteamwarUser.getUsersWithPerm(it) }
|
||||||
|
.mapKeys { UserPerm.prefixes[it.key]!!.chatPrefix }
|
||||||
.mapValues { it.value.map { ResponseUser(it) } }
|
.mapValues { it.value.map { ResponseUser(it) } }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ data class PageResponse(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class CreatePageRequest(val path: String)
|
data class CreatePageRequest(val path: String, val slug: String?, val title: String?)
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class CreateBranchRequest(val branch: String)
|
data class CreateBranchRequest(val branch: String)
|
||||||
@ -177,23 +177,23 @@ fun Route.configurePage() {
|
|||||||
@Serializable
|
@Serializable
|
||||||
data class CreateGiteaPageRequest(val message: String, val content: String, val branch: String, val author: Identity)
|
data class CreateGiteaPageRequest(val message: String, val content: String, val branch: String, val author: Identity)
|
||||||
|
|
||||||
val path = call.receive<CreatePageRequest>().path
|
val req = call.receive<CreatePageRequest>()
|
||||||
if(path.startsWith("src/content/")) {
|
if(req.path.startsWith("src/content/")) {
|
||||||
call.respond(HttpStatusCode.BadRequest, "Invalid path")
|
call.respond(HttpStatusCode.BadRequest, "Invalid path")
|
||||||
return@post
|
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)
|
contentType(ContentType.Application.Json)
|
||||||
setBody(CreateGiteaPageRequest(
|
setBody(CreateGiteaPageRequest(
|
||||||
"Create page $path",
|
"Create page ${req.path}",
|
||||||
Base64.getEncoder().encodeToString("""
|
Base64.getEncoder().encodeToString("""
|
||||||
---
|
---
|
||||||
title: [Enter Title]
|
title: ${req.title ?: "[Enter Title]"}
|
||||||
description: [Enter Description]
|
description: [Enter Description]
|
||||||
slug: [Enter Slug]
|
slug: ${req.slug ?: "[Enter Slug]"}
|
||||||
---
|
---
|
||||||
|
|
||||||
# $path
|
# ${req.path}
|
||||||
""".trimIndent().toByteArray()),
|
""".trimIndent().toByteArray()),
|
||||||
call.request.queryParameters["branch"] ?: "master",
|
call.request.queryParameters["branch"] ?: "master",
|
||||||
Identity(call.principal<SWAuthPrincipal>()!!.user.userName, "admin-tool@steamwar.de"
|
Identity(call.principal<SWAuthPrincipal>()!!.user.userName, "admin-tool@steamwar.de"
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren