Extension API 1.6 (#2120)

* Non-Extension Index changes for 1.6

* Changelog

* Minor fixes

* Implement extension store

* Test build fix

* Docs

* Simplify fetching manga and chapters

* Use EMPTY JsonObject

* Update docs/Configuring-Suwayomi‐Server.md

Co-authored-by: Constantin Piber <59023762+cpiber@users.noreply.github.com>

* Improve Fetch Extension Store

* Fixes

* Simplify deprecated isNsfw in SourceQuery

* Simplify ContentRating in Source.kt

* Simplify isNsfw in SourceType

* No magic numbers for ContentRating, improves safety for future versions of extension api

* Fix SearchTest

* Lint

* Lint

* Optimize imports and fix unchecked cast warning

* Proper extension store queries

* Optimize import fixes

* Add ContentRatingFilter

* Improve extension store sync

* fix: re-sync (#2121)

* Lint

* Add ExtenionStores to the fetchExtensions result since its possible for the stores to change.

* Use a single version of ContentRating

* Exclude ServerConfig.extensionStores from GraphQL

* Use syncDbToPrefs in ExtensionStoreMutation

* Optimize Imports

* Update server/server-config/src/main/kotlin/suwayomi/tachidesk/server/ServerConfig.kt

Co-authored-by: Constantin Piber <59023762+cpiber@users.noreply.github.com>

* Remove replaceWith and add specific description for GQL APIs

* Include OkHttp ZSTD

* Update to latest Mihon extension lib

* Fix latest Mihon Extension Lib

* Lint

* Optimize imports

* Lint

* Review fixes

* Add a index to extesnion table store url

* Lint

---------

Co-authored-by: Constantin Piber <59023762+cpiber@users.noreply.github.com>
This commit is contained in:
Mitchell Syer
2026-06-27 13:39:28 -04:00
committed by GitHub
parent c8f5d83e9c
commit 2d535b44d8
84 changed files with 2576 additions and 1007 deletions

View File

@@ -2,6 +2,7 @@
package suwayomi.tachidesk.graphql.mutations
import com.expediagroup.graphql.generator.annotations.GraphQLDeprecated
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import org.jetbrains.exposed.v1.core.LikePattern
@@ -25,6 +26,7 @@ import suwayomi.tachidesk.graphql.types.ChapterType
import suwayomi.tachidesk.graphql.types.MetaInput
import suwayomi.tachidesk.graphql.types.SyncConflictInfoType
import suwayomi.tachidesk.manga.impl.Chapter
import suwayomi.tachidesk.manga.impl.Manga
import suwayomi.tachidesk.manga.impl.chapter.getChapterDownloadReadyById
import suwayomi.tachidesk.manga.impl.sync.KoreaderSyncService
import suwayomi.tachidesk.manga.model.table.ChapterMetaTable
@@ -167,11 +169,12 @@ class ChapterMutation {
)
@RequireAuth
@GraphQLDeprecated("Deprecated in Tachiyomix 1.6", ReplaceWith("fetchMangaAndChapters"))
fun fetchChapters(input: FetchChaptersInput): CompletableFuture<FetchChaptersPayload?> {
val (clientMutationId, mangaId) = input
return future {
Chapter.fetchChapterList(mangaId)
Manga.updateMangaAndChapters(mangaId, updateManga = false)
val chapters =
transaction {

View File

@@ -10,9 +10,11 @@ import org.jetbrains.exposed.v1.core.neq
import org.jetbrains.exposed.v1.jdbc.selectAll
import org.jetbrains.exposed.v1.jdbc.transactions.transaction
import suwayomi.tachidesk.graphql.directives.RequireAuth
import suwayomi.tachidesk.graphql.types.ExtensionStoreType
import suwayomi.tachidesk.graphql.types.ExtensionType
import suwayomi.tachidesk.manga.impl.extension.Extension
import suwayomi.tachidesk.manga.impl.extension.ExtensionsList
import suwayomi.tachidesk.manga.model.table.ExtensionStoreTable
import suwayomi.tachidesk.manga.model.table.ExtensionTable
import suwayomi.tachidesk.server.JavalinSetup.future
import java.util.concurrent.CompletableFuture
@@ -129,6 +131,7 @@ class ExtensionMutation {
data class FetchExtensionsPayload(
val clientMutationId: String?,
val extensions: List<ExtensionType>,
val extensionStores: List<ExtensionStoreType>,
)
@RequireAuth
@@ -146,9 +149,17 @@ class ExtensionMutation {
.map { ExtensionType(it) }
}
val extensionStores =
transaction {
ExtensionStoreTable
.selectAll()
.map { ExtensionStoreType(it) }
}
FetchExtensionsPayload(
clientMutationId = clientMutationId,
extensions = extensions,
extensionStores = extensionStores,
)
}
}

View File

@@ -0,0 +1,104 @@
package suwayomi.tachidesk.graphql.mutations
/*
* Copyright (C) Contributors to the Suwayomi project
*
* This Source Code Form is subject to the terms of the Mozilla Public
* 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 org.jetbrains.exposed.v1.core.eq
import org.jetbrains.exposed.v1.jdbc.deleteWhere
import org.jetbrains.exposed.v1.jdbc.selectAll
import org.jetbrains.exposed.v1.jdbc.transactions.transaction
import suwayomi.tachidesk.graphql.directives.RequireAuth
import suwayomi.tachidesk.graphql.types.ExtensionStoreType
import suwayomi.tachidesk.manga.impl.extension.ExtensionStoreService
import suwayomi.tachidesk.manga.model.table.ExtensionStoreTable
import suwayomi.tachidesk.server.JavalinSetup.future
import java.util.concurrent.CompletableFuture
class ExtensionStoreMutation {
data class AddExtensionStoreInput(
val clientMutationId: String? = null,
val indexUrl: String,
)
data class AddExtensionStorePayload(
val clientMutationId: String?,
val extensionStore: ExtensionStoreType,
)
@RequireAuth
fun addExtensionStore(input: AddExtensionStoreInput): CompletableFuture<AddExtensionStorePayload?> {
val (clientMutationId, indexUrl) = input
return future {
val store = ExtensionStoreService.fetch(indexUrl)
ExtensionStoreService.upsert(store)
ExtensionStoreService.syncDbToPrefs()
val row =
transaction {
ExtensionStoreTable
.selectAll()
.where { ExtensionStoreTable.indexUrl eq store.indexUrl }
.first()
}
AddExtensionStorePayload(
clientMutationId = clientMutationId,
extensionStore = ExtensionStoreType(row),
)
}
}
data class RemoveExtensionStoreInput(
val clientMutationId: String? = null,
val indexUrl: String,
)
data class RemoveExtensionStorePayload(
val clientMutationId: String?,
val extensionStore: ExtensionStoreType?,
)
@RequireAuth
fun removeExtensionStore(input: RemoveExtensionStoreInput): CompletableFuture<RemoveExtensionStorePayload?> {
val (clientMutationId, indexUrl) = input
return future {
val store =
transaction {
ExtensionStoreTable
.selectAll()
.where { ExtensionStoreTable.indexUrl eq indexUrl }
.firstOrNull()
?.let { ExtensionStoreType(it) }
}
store?.let {
transaction {
ExtensionStoreTable.deleteWhere { ExtensionStoreTable.indexUrl eq indexUrl }
}
}
ExtensionStoreService.syncDbToPrefs()
RemoveExtensionStorePayload(
clientMutationId = clientMutationId,
extensionStore =
store?.let {
ExtensionStoreType(
name = it.name,
badgeLabel = it.badgeLabel,
signingKey = it.signingKey,
contactWebsite = it.contactWebsite,
contactDiscord = it.contactDiscord,
indexUrl = it.indexUrl,
isLegacy = it.isLegacy,
extensionListUrl = it.extensionListUrl,
)
},
)
}
}
}

View File

@@ -2,6 +2,7 @@
package suwayomi.tachidesk.graphql.mutations
import com.expediagroup.graphql.generator.annotations.GraphQLDeprecated
import org.jetbrains.exposed.v1.core.LikePattern
import org.jetbrains.exposed.v1.core.Op
import org.jetbrains.exposed.v1.core.and
@@ -14,12 +15,14 @@ import org.jetbrains.exposed.v1.jdbc.selectAll
import org.jetbrains.exposed.v1.jdbc.transactions.transaction
import org.jetbrains.exposed.v1.jdbc.update
import suwayomi.tachidesk.graphql.directives.RequireAuth
import suwayomi.tachidesk.graphql.types.ChapterType
import suwayomi.tachidesk.graphql.types.MangaMetaType
import suwayomi.tachidesk.graphql.types.MangaType
import suwayomi.tachidesk.graphql.types.MetaInput
import suwayomi.tachidesk.manga.impl.Library
import suwayomi.tachidesk.manga.impl.Manga
import suwayomi.tachidesk.manga.impl.update.IUpdater
import suwayomi.tachidesk.manga.model.table.ChapterTable
import suwayomi.tachidesk.manga.model.table.MangaMetaTable
import suwayomi.tachidesk.manga.model.table.MangaTable
import suwayomi.tachidesk.manga.model.table.toDataClass
@@ -146,11 +149,12 @@ class MangaMutation {
)
@RequireAuth
@GraphQLDeprecated("Deprecated in Tachiyomix 1.6", ReplaceWith("fetchMangaAndChapters"))
fun fetchManga(input: FetchMangaInput): CompletableFuture<FetchMangaPayload?> {
val (clientMutationId, id) = input
return future {
Manga.fetchManga(id)
Manga.updateMangaAndChapters(id, updateChapters = false)
val manga =
transaction {
@@ -163,6 +167,49 @@ class MangaMutation {
}
}
data class FetchMangaAndChaptersInput(
val clientMutationId: String? = null,
val id: Int,
val fetchManga: Boolean,
val fetchChapters: Boolean,
)
data class FetchMangaAndChaptersPayload(
val clientMutationId: String?,
val manga: MangaType,
val chapters: List<ChapterType>,
)
@RequireAuth
fun fetchMangaAndChapters(input: FetchMangaAndChaptersInput): CompletableFuture<FetchMangaAndChaptersPayload?> {
val (clientMutationId, id, fetchManga, fetchChapters) = input
return future {
Manga.updateMangaAndChapters(
mangaId = id,
updateManga = fetchManga,
updateChapters = fetchChapters,
)
val (manga, chapters) =
transaction {
Pair(
MangaTable.selectAll().where { MangaTable.id eq id }.first(),
ChapterTable
.selectAll()
.where { ChapterTable.manga eq id }
.orderBy(ChapterTable.sourceOrder)
.map { ChapterType(it) },
)
}
FetchMangaAndChaptersPayload(
clientMutationId = clientMutationId,
manga = MangaType(manga),
chapters = chapters,
)
}
}
data class SetMangaMetaInput(
val clientMutationId: String? = null,
val meta: MangaMetaType,