mirror of
https://github.com/Suwayomi/Suwayomi-Server.git
synced 2026-07-04 03:14:40 -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:
@@ -9,6 +9,7 @@ package suwayomi.tachidesk.graphql.controller
|
||||
|
||||
import io.javalin.http.ContentType
|
||||
import io.javalin.http.Context
|
||||
import io.javalin.http.HttpStatus
|
||||
import io.javalin.websocket.WsConfig
|
||||
import suwayomi.tachidesk.graphql.server.TachideskGraphQLServer
|
||||
import suwayomi.tachidesk.graphql.server.TemporaryFileStorage
|
||||
@@ -20,11 +21,17 @@ object GraphQLController {
|
||||
|
||||
/** execute graphql query */
|
||||
fun execute(ctx: Context) {
|
||||
ctx.future(
|
||||
ctx.future {
|
||||
future {
|
||||
server.execute(ctx)
|
||||
},
|
||||
)
|
||||
}.thenApply {
|
||||
if (it != null) {
|
||||
ctx.json(it)
|
||||
} else {
|
||||
ctx.status(HttpStatus.BAD_REQUEST)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun playground(ctx: Context) {
|
||||
|
||||
@@ -30,7 +30,7 @@ class BackupMutation {
|
||||
val (clientMutationId, backup) = input
|
||||
|
||||
return future {
|
||||
val restoreId = ProtoBackupImport.restore(backup.content)
|
||||
val restoreId = ProtoBackupImport.restore(backup.content())
|
||||
|
||||
withTimeout(10.seconds) {
|
||||
ProtoBackupImport.notifyFlow.first {
|
||||
|
||||
@@ -165,9 +165,9 @@ class ExtensionMutation {
|
||||
|
||||
return future {
|
||||
asDataFetcherResult {
|
||||
Extension.installExternalExtension(extensionFile.content, extensionFile.filename)
|
||||
Extension.installExternalExtension(extensionFile.content(), extensionFile.filename())
|
||||
|
||||
val dbExtension = transaction { ExtensionTable.select { ExtensionTable.apkName eq extensionFile.filename }.first() }
|
||||
val dbExtension = transaction { ExtensionTable.select { ExtensionTable.apkName eq extensionFile.filename() }.first() }
|
||||
|
||||
InstallExternalExtensionPayload(
|
||||
clientMutationId,
|
||||
|
||||
@@ -26,7 +26,7 @@ class BackupQuery {
|
||||
)
|
||||
|
||||
fun validateBackup(input: ValidateBackupInput): ValidateBackupResult {
|
||||
val result = ProtoBackupValidator.validate(input.backup.content)
|
||||
val result = ProtoBackupValidator.validate(input.backup.content())
|
||||
return ValidateBackupResult(
|
||||
result.missingSourceIds.map { ValidateBackupSource(it.first, it.second) },
|
||||
result.missingTrackers.map { ValidateBackupTracker(it) },
|
||||
|
||||
@@ -13,7 +13,7 @@ import com.expediagroup.graphql.server.types.GraphQLRequest
|
||||
import com.expediagroup.graphql.server.types.GraphQLServerRequest
|
||||
import io.javalin.http.Context
|
||||
import io.javalin.http.UploadedFile
|
||||
import io.javalin.plugin.json.jsonMapper
|
||||
import io.javalin.json.fromJsonString
|
||||
import java.io.IOException
|
||||
|
||||
class JavalinGraphQLRequestParser : GraphQLRequestParser<Context> {
|
||||
@@ -33,20 +33,13 @@ class JavalinGraphQLRequestParser : GraphQLRequestParser<Context> {
|
||||
}
|
||||
|
||||
val request =
|
||||
context.jsonMapper().fromJsonString(
|
||||
formParam,
|
||||
GraphQLServerRequest::class.java,
|
||||
)
|
||||
context.jsonMapper().fromJsonString<GraphQLServerRequest>(formParam)
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val map =
|
||||
context
|
||||
.formParam("map")
|
||||
?.let {
|
||||
context.jsonMapper().fromJsonString(
|
||||
it,
|
||||
Map::class.java as Class<Map<String, List<String>>>,
|
||||
)
|
||||
context.jsonMapper().fromJsonString<Map<String, List<String>>>(it)
|
||||
}.orEmpty()
|
||||
|
||||
val mapItems =
|
||||
|
||||
@@ -69,7 +69,7 @@ class ApolloSubscriptionProtocolHandler(
|
||||
|
||||
if (operationMessage.type != GQL_PING.type) {
|
||||
logger.debug {
|
||||
"GraphQL subscription client message, sessionId=${context.sessionId} type=${operationMessage.type} operationName=${
|
||||
"GraphQL subscription client message, sessionId=${context.sessionId()} type=${operationMessage.type} operationName=${
|
||||
getOperationName(operationMessage.payload)
|
||||
} ${
|
||||
if (serverConfig.gqlDebugLogsEnabled.value) {
|
||||
@@ -118,7 +118,7 @@ class ApolloSubscriptionProtocolHandler(
|
||||
|
||||
if (sessionState.doesOperationExist(operationMessage)) {
|
||||
sessionState.terminateSession(context, CloseStatus(4409, "Subscriber for ${operationMessage.id} already exists"))
|
||||
logger.info("Already subscribed to operation ${operationMessage.id} for session ${context.sessionId}")
|
||||
logger.info("Already subscribed to operation ${operationMessage.id} for session ${context.sessionId()}")
|
||||
return emptyFlow()
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ class ApolloSubscriptionProtocolHandler(
|
||||
private fun onPing(): Flow<SubscriptionOperationMessage> = flowOf(pongMessage)
|
||||
|
||||
private fun onDisconnect(context: WsContext): Flow<SubscriptionOperationMessage> {
|
||||
logger.debug("Session \"${context.sessionId}\" disconnected")
|
||||
logger.debug("Session \"${context.sessionId()}\" disconnected")
|
||||
sessionState.terminateSession(context, CloseStatus(1000, "Normal Closure"))
|
||||
return emptyFlow()
|
||||
}
|
||||
|
||||
@@ -36,14 +36,14 @@ internal class ApolloSubscriptionSessionState {
|
||||
context: WsContext,
|
||||
graphQLContext: GraphQLContext,
|
||||
) {
|
||||
cachedGraphQLContext[context.sessionId] = graphQLContext
|
||||
cachedGraphQLContext[context.sessionId()] = graphQLContext
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the graphQL context for this session.
|
||||
*/
|
||||
fun getGraphQLContext(context: WsContext): GraphQLContext =
|
||||
cachedGraphQLContext[context.sessionId] ?: emptyMap<Any, Any>().toGraphQLContext()
|
||||
cachedGraphQLContext[context.sessionId()] ?: emptyMap<Any, Any>().toGraphQLContext()
|
||||
|
||||
/**
|
||||
* Save the operation that is sending data to the client.
|
||||
@@ -58,7 +58,7 @@ internal class ApolloSubscriptionSessionState {
|
||||
val id = operationMessage.id
|
||||
if (id != null) {
|
||||
activeOperations[id] = subscription
|
||||
sessionToOperationId.getOrPut(context.sessionId) { CopyOnWriteArrayList() } += id
|
||||
sessionToOperationId.getOrPut(context.sessionId()) { CopyOnWriteArrayList() } += id
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,10 +87,10 @@ internal class ApolloSubscriptionSessionState {
|
||||
context: WsContext,
|
||||
code: CloseStatus,
|
||||
) {
|
||||
sessionToOperationId.remove(context.sessionId)?.forEach {
|
||||
sessionToOperationId.remove(context.sessionId())?.forEach {
|
||||
removeActiveOperation(it)
|
||||
}
|
||||
cachedGraphQLContext.remove(context.sessionId)
|
||||
cachedGraphQLContext.remove(context.sessionId())
|
||||
context.closeSession(code)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user