mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-11 06:44:34 -05:00
Update dependency io.javalin:javalin to v6 (#1152)
* Update dependency io.javalin:javalin to v6 * Simple compile fixes * Simple compile fixes pass 2 * Add results to futures * Setup jetty server and api routes * Setup Cors * Setup basic auth * Documentation stubs * Replace chapter mutex cache * Fix compile * Disable Jetty Logging --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Syer10 <syer10@users.noreply.github.com>
This commit is contained in:
@@ -7,13 +7,12 @@ package suwayomi.tachidesk.manga.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 com.google.common.cache.Cache
|
||||
import com.google.common.cache.CacheBuilder
|
||||
import eu.kanade.tachiyomi.source.model.SChapter
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import eu.kanade.tachiyomi.util.chapter.ChapterRecognition
|
||||
import eu.kanade.tachiyomi.util.chapter.ChapterSanitizer.sanitize
|
||||
import io.github.reactivecircus.cache4k.Cache
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
import kotlinx.serialization.Serializable
|
||||
@@ -47,8 +46,8 @@ import suwayomi.tachidesk.manga.model.table.toDataClass
|
||||
import suwayomi.tachidesk.server.serverConfig
|
||||
import java.time.Instant
|
||||
import java.util.TreeSet
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.math.max
|
||||
import kotlin.time.Duration.Companion.minutes
|
||||
|
||||
private fun List<ChapterDataClass>.removeDuplicates(currentChapter: ChapterDataClass): List<ChapterDataClass> =
|
||||
groupBy { it.chapterNumber }
|
||||
@@ -124,9 +123,9 @@ object Chapter {
|
||||
}
|
||||
|
||||
val map: Cache<Int, Mutex> =
|
||||
CacheBuilder
|
||||
.newBuilder()
|
||||
.expireAfterAccess(10, TimeUnit.MINUTES)
|
||||
Cache
|
||||
.Builder<Int, Mutex>()
|
||||
.expireAfterAccess(10.minutes)
|
||||
.build()
|
||||
|
||||
suspend fun fetchChapterList(mangaId: Int): List<SChapter> {
|
||||
|
||||
@@ -15,7 +15,7 @@ import eu.kanade.tachiyomi.source.local.LocalSource
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.source.model.UpdateStrategy
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import io.javalin.http.HttpCode
|
||||
import io.javalin.http.HttpStatus
|
||||
import mu.KLogger
|
||||
import mu.KotlinLogging
|
||||
import okhttp3.CacheControl
|
||||
@@ -305,9 +305,9 @@ object Manga {
|
||||
val tryToRefreshUrl =
|
||||
!refreshUrl &&
|
||||
listOf(
|
||||
HttpCode.GONE.status,
|
||||
HttpCode.MOVED_PERMANENTLY.status,
|
||||
HttpCode.NOT_FOUND.status,
|
||||
HttpStatus.GONE.code,
|
||||
HttpStatus.MOVED_PERMANENTLY.code,
|
||||
HttpStatus.NOT_FOUND.code,
|
||||
523, // (Cloudflare) Origin Is Unreachable
|
||||
522, // (Cloudflare) Connection timed out
|
||||
).contains(e.code)
|
||||
|
||||
@@ -10,7 +10,8 @@ package suwayomi.tachidesk.manga.impl
|
||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||
import eu.kanade.tachiyomi.source.model.Filter
|
||||
import eu.kanade.tachiyomi.source.model.FilterList
|
||||
import io.javalin.plugin.json.JsonMapper
|
||||
import io.javalin.json.JsonMapper
|
||||
import io.javalin.json.fromJsonString
|
||||
import kotlinx.serialization.Serializable
|
||||
import suwayomi.tachidesk.manga.impl.MangaList.processEntries
|
||||
import suwayomi.tachidesk.manga.impl.util.source.GetCatalogueSource.getCatalogueSourceOrStub
|
||||
@@ -129,7 +130,7 @@ object Search {
|
||||
is Filter.CheckBox -> filter.state = change.state.toBooleanStrict()
|
||||
is Filter.TriState -> filter.state = change.state.toInt()
|
||||
is Filter.Group<*> -> {
|
||||
val groupChange = jsonMapper.fromJsonString(change.state, FilterChange::class.java)
|
||||
val groupChange = jsonMapper.fromJsonString<FilterChange>(change.state)
|
||||
|
||||
when (val groupFilter = filter.state[groupChange.position]) {
|
||||
is Filter.CheckBox -> groupFilter.state = groupChange.state.toBooleanStrict()
|
||||
|
||||
@@ -11,7 +11,8 @@ import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceScreen
|
||||
import eu.kanade.tachiyomi.source.ConfigurableSource
|
||||
import eu.kanade.tachiyomi.source.sourcePreferences
|
||||
import io.javalin.plugin.json.JsonMapper
|
||||
import io.javalin.json.JsonMapper
|
||||
import io.javalin.json.fromJsonString
|
||||
import mu.KotlinLogging
|
||||
import org.jetbrains.exposed.sql.and
|
||||
import org.jetbrains.exposed.sql.insert
|
||||
@@ -131,11 +132,10 @@ object Source {
|
||||
value: String,
|
||||
getValue: (Preference) -> Any = { pref ->
|
||||
println(jsonMapper::class.java.name)
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
when (pref.defaultValueType) {
|
||||
"String" -> value
|
||||
"Boolean" -> value.toBoolean()
|
||||
"Set<String>" -> jsonMapper.fromJsonString(value, List::class.java as Class<List<String>>).toSet()
|
||||
"Set<String>" -> jsonMapper.fromJsonString<List<String>>(value).toSet()
|
||||
else -> throw RuntimeException("Unsupported type conversion")
|
||||
}
|
||||
},
|
||||
|
||||
@@ -104,11 +104,11 @@ object DownloadManager {
|
||||
}
|
||||
|
||||
fun addClient(ctx: WsContext) {
|
||||
clients[ctx.sessionId] = ctx
|
||||
clients[ctx.sessionId()] = ctx
|
||||
}
|
||||
|
||||
fun removeClient(ctx: WsContext) {
|
||||
clients.remove(ctx.sessionId)
|
||||
clients.remove(ctx.sessionId())
|
||||
}
|
||||
|
||||
fun notifyClient(ctx: WsContext) {
|
||||
|
||||
@@ -41,7 +41,7 @@ object UpdaterSocket : Websocket<UpdateStatus>() {
|
||||
}
|
||||
|
||||
override fun addClient(ctx: WsContext) {
|
||||
logger.info { ctx.sessionId }
|
||||
logger.info { ctx.sessionId() }
|
||||
super.addClient(ctx)
|
||||
if (job?.isActive != true) {
|
||||
job = start()
|
||||
|
||||
@@ -8,12 +8,12 @@ abstract class Websocket<T> {
|
||||
protected val clients = ConcurrentHashMap<String, WsContext>()
|
||||
|
||||
open fun addClient(ctx: WsContext) {
|
||||
clients[ctx.sessionId] = ctx
|
||||
clients[ctx.sessionId()] = ctx
|
||||
notifyClient(ctx, null)
|
||||
}
|
||||
|
||||
open fun removeClient(ctx: WsContext) {
|
||||
clients.remove(ctx.sessionId)
|
||||
clients.remove(ctx.sessionId())
|
||||
}
|
||||
|
||||
open fun notifyAllClients(value: T) {
|
||||
|
||||
Reference in New Issue
Block a user