mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-10 14:24:34 -05:00
Improve Tracker Icons Implementation (#836)
* Improve tracker icons implementation * Fix description
This commit is contained in:
@@ -17,8 +17,10 @@ import suwayomi.tachidesk.manga.impl.track.Track
|
||||
import suwayomi.tachidesk.manga.model.dataclass.TrackerDataClass
|
||||
import suwayomi.tachidesk.server.JavalinSetup.future
|
||||
import suwayomi.tachidesk.server.util.handler
|
||||
import suwayomi.tachidesk.server.util.pathParam
|
||||
import suwayomi.tachidesk.server.util.queryParam
|
||||
import suwayomi.tachidesk.server.util.withOperation
|
||||
import kotlin.time.Duration.Companion.days
|
||||
|
||||
object TrackController {
|
||||
private val json by DI.global.instance<Json>()
|
||||
@@ -136,4 +138,30 @@ object TrackController {
|
||||
httpCode(HttpCode.OK)
|
||||
},
|
||||
)
|
||||
|
||||
val thumbnail =
|
||||
handler(
|
||||
pathParam<Int>("trackerId"),
|
||||
documentWith = {
|
||||
withOperation {
|
||||
summary("Get a tracker thumbnail")
|
||||
description("Get a tracker thumbnail from the resources.")
|
||||
}
|
||||
},
|
||||
behaviorOf = { ctx, trackerId ->
|
||||
ctx.future(
|
||||
future { Track.getTrackerThumbnail(trackerId) }
|
||||
.thenApply {
|
||||
ctx.header("content-type", it.second)
|
||||
val httpCacheSeconds = 1.days.inWholeSeconds
|
||||
ctx.header("cache-control", "max-age=$httpCacheSeconds")
|
||||
it.first
|
||||
},
|
||||
)
|
||||
},
|
||||
withResults = {
|
||||
image(HttpCode.OK)
|
||||
httpCode(HttpCode.NOT_FOUND)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user