mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-08 05:14:37 -05:00
Switch to a new Ktlint Formatter (#705)
* Switch to new Ktlint plugin * Add ktlintCheck to PR builds * Run formatter * Put ktlint version in libs toml * Fix lint * Use Zip4Java from libs.toml
This commit is contained in:
@@ -15,39 +15,41 @@ import suwayomi.tachidesk.server.util.withOperation
|
||||
|
||||
object GlobalMetaController {
|
||||
/** used to modify a category's meta parameters */
|
||||
val getMeta = handler(
|
||||
documentWith = {
|
||||
withOperation {
|
||||
summary("Server level meta mapping")
|
||||
description("Get a list of globally stored key-value mapping, you can set values for whatever you want inside it.")
|
||||
}
|
||||
},
|
||||
behaviorOf = { ctx ->
|
||||
ctx.json(GlobalMeta.getMetaMap())
|
||||
ctx.status(200)
|
||||
},
|
||||
withResults = {
|
||||
httpCode(HttpCode.OK)
|
||||
}
|
||||
)
|
||||
val getMeta =
|
||||
handler(
|
||||
documentWith = {
|
||||
withOperation {
|
||||
summary("Server level meta mapping")
|
||||
description("Get a list of globally stored key-value mapping, you can set values for whatever you want inside it.")
|
||||
}
|
||||
},
|
||||
behaviorOf = { ctx ->
|
||||
ctx.json(GlobalMeta.getMetaMap())
|
||||
ctx.status(200)
|
||||
},
|
||||
withResults = {
|
||||
httpCode(HttpCode.OK)
|
||||
},
|
||||
)
|
||||
|
||||
/** used to modify global meta parameters */
|
||||
val modifyMeta = handler(
|
||||
formParam<String>("key"),
|
||||
formParam<String>("value"),
|
||||
documentWith = {
|
||||
withOperation {
|
||||
summary("Add meta data to the global meta mapping")
|
||||
description("A simple Key-Value stored at server global level, you can set values for whatever you want inside it.")
|
||||
}
|
||||
},
|
||||
behaviorOf = { ctx, key, value ->
|
||||
GlobalMeta.modifyMeta(key, value)
|
||||
ctx.status(200)
|
||||
},
|
||||
withResults = {
|
||||
httpCode(HttpCode.OK)
|
||||
httpCode(HttpCode.NOT_FOUND)
|
||||
}
|
||||
)
|
||||
val modifyMeta =
|
||||
handler(
|
||||
formParam<String>("key"),
|
||||
formParam<String>("value"),
|
||||
documentWith = {
|
||||
withOperation {
|
||||
summary("Add meta data to the global meta mapping")
|
||||
description("A simple Key-Value stored at server global level, you can set values for whatever you want inside it.")
|
||||
}
|
||||
},
|
||||
behaviorOf = { ctx, key, value ->
|
||||
GlobalMeta.modifyMeta(key, value)
|
||||
ctx.status(200)
|
||||
},
|
||||
withResults = {
|
||||
httpCode(HttpCode.OK)
|
||||
httpCode(HttpCode.NOT_FOUND)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -19,36 +19,38 @@ import suwayomi.tachidesk.server.util.withOperation
|
||||
/** Settings Page/Screen */
|
||||
object SettingsController {
|
||||
/** returns some static info about the current app build */
|
||||
val about = handler(
|
||||
documentWith = {
|
||||
withOperation {
|
||||
summary("About Tachidesk")
|
||||
description("Returns some static info about the current app build")
|
||||
}
|
||||
},
|
||||
behaviorOf = { ctx ->
|
||||
ctx.json(About.getAbout())
|
||||
},
|
||||
withResults = {
|
||||
json<AboutDataClass>(HttpCode.OK)
|
||||
}
|
||||
)
|
||||
val about =
|
||||
handler(
|
||||
documentWith = {
|
||||
withOperation {
|
||||
summary("About Tachidesk")
|
||||
description("Returns some static info about the current app build")
|
||||
}
|
||||
},
|
||||
behaviorOf = { ctx ->
|
||||
ctx.json(About.getAbout())
|
||||
},
|
||||
withResults = {
|
||||
json<AboutDataClass>(HttpCode.OK)
|
||||
},
|
||||
)
|
||||
|
||||
/** check for app updates */
|
||||
val checkUpdate = handler(
|
||||
documentWith = {
|
||||
withOperation {
|
||||
summary("Tachidesk update check")
|
||||
description("Check for app updates")
|
||||
}
|
||||
},
|
||||
behaviorOf = { ctx ->
|
||||
ctx.future(
|
||||
future { AppUpdate.checkUpdate() }
|
||||
)
|
||||
},
|
||||
withResults = {
|
||||
json<Array<UpdateDataClass>>(HttpCode.OK)
|
||||
}
|
||||
)
|
||||
val checkUpdate =
|
||||
handler(
|
||||
documentWith = {
|
||||
withOperation {
|
||||
summary("Tachidesk update check")
|
||||
description("Check for app updates")
|
||||
}
|
||||
},
|
||||
behaviorOf = { ctx ->
|
||||
ctx.future(
|
||||
future { AppUpdate.checkUpdate() },
|
||||
)
|
||||
},
|
||||
withResults = {
|
||||
json<Array<UpdateDataClass>>(HttpCode.OK)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ package suwayomi.tachidesk.global.impl
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
import suwayomi.tachidesk.server.BuildConfig
|
||||
import suwayomi.tachidesk.server.generated.BuildConfig
|
||||
|
||||
data class AboutDataClass(
|
||||
val name: String,
|
||||
@@ -16,7 +16,7 @@ data class AboutDataClass(
|
||||
val buildType: String,
|
||||
val buildTime: Long,
|
||||
val github: String,
|
||||
val discord: String
|
||||
val discord: String,
|
||||
)
|
||||
|
||||
object About {
|
||||
@@ -28,7 +28,7 @@ object About {
|
||||
BuildConfig.BUILD_TYPE,
|
||||
BuildConfig.BUILD_TIME,
|
||||
BuildConfig.GITHUB,
|
||||
BuildConfig.DISCORD
|
||||
BuildConfig.DISCORD,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ data class UpdateDataClass(
|
||||
/** [channel] mirrors [suwayomi.tachidesk.server.BuildConfig.BUILD_TYPE] */
|
||||
val channel: String,
|
||||
val tag: String,
|
||||
val url: String
|
||||
val url: String,
|
||||
)
|
||||
|
||||
object AppUpdate {
|
||||
@@ -30,29 +30,31 @@ object AppUpdate {
|
||||
private val network: NetworkHelper by injectLazy()
|
||||
|
||||
suspend fun checkUpdate(): List<UpdateDataClass> {
|
||||
val stableJson = json.parseToJsonElement(
|
||||
network.client.newCall(
|
||||
GET(LATEST_STABLE_CHANNEL_URL)
|
||||
).await().body.string()
|
||||
).jsonObject
|
||||
val stableJson =
|
||||
json.parseToJsonElement(
|
||||
network.client.newCall(
|
||||
GET(LATEST_STABLE_CHANNEL_URL),
|
||||
).await().body.string(),
|
||||
).jsonObject
|
||||
|
||||
val previewJson = json.parseToJsonElement(
|
||||
network.client.newCall(
|
||||
GET(LATEST_PREVIEW_CHANNEL_URL)
|
||||
).await().body.string()
|
||||
).jsonObject
|
||||
val previewJson =
|
||||
json.parseToJsonElement(
|
||||
network.client.newCall(
|
||||
GET(LATEST_PREVIEW_CHANNEL_URL),
|
||||
).await().body.string(),
|
||||
).jsonObject
|
||||
|
||||
return listOf(
|
||||
UpdateDataClass(
|
||||
"Stable",
|
||||
stableJson["tag_name"]!!.jsonPrimitive.content,
|
||||
stableJson["html_url"]!!.jsonPrimitive.content
|
||||
stableJson["html_url"]!!.jsonPrimitive.content,
|
||||
),
|
||||
UpdateDataClass(
|
||||
"Preview",
|
||||
previewJson["tag_name"]!!.jsonPrimitive.content,
|
||||
previewJson["html_url"]!!.jsonPrimitive.content
|
||||
)
|
||||
previewJson["html_url"]!!.jsonPrimitive.content,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,11 +15,15 @@ import suwayomi.tachidesk.global.model.table.GlobalMetaTable
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
object GlobalMeta {
|
||||
fun modifyMeta(key: String, value: String) {
|
||||
fun modifyMeta(
|
||||
key: String,
|
||||
value: String,
|
||||
) {
|
||||
transaction {
|
||||
val meta = transaction {
|
||||
GlobalMetaTable.select { GlobalMetaTable.key eq key }
|
||||
}.firstOrNull()
|
||||
val meta =
|
||||
transaction {
|
||||
GlobalMetaTable.select { GlobalMetaTable.key eq key }
|
||||
}.firstOrNull()
|
||||
|
||||
if (meta == null) {
|
||||
GlobalMetaTable.insert {
|
||||
|
||||
Reference in New Issue
Block a user