diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/ExtensionQuery.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/ExtensionQuery.kt index 615609892..d7f085eed 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/ExtensionQuery.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/ExtensionQuery.kt @@ -126,7 +126,7 @@ class ExtensionQuery { opAnd.eq(versionCode?.toLong(), ExtensionTable.versionCode) opAnd.eq(versionCodeLong, ExtensionTable.versionCode) opAnd.eq(lang, ExtensionTable.lang) - opAnd.eq(isNsfw?.let { if (it) 3 else 0 }, ExtensionTable.contentRating) + opAnd.eq(isNsfw?.let { if (it) ContentRating.PORNOGRAPHIC.ordinal else ContentRating.SAFE.ordinal }, ExtensionTable.contentRating) opAnd.eq(contentRating?.ordinal, ExtensionTable.contentRating) opAnd.eq(isInstalled, ExtensionTable.isInstalled) opAnd.eq(hasUpdate, ExtensionTable.hasUpdate) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/SourceQuery.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/SourceQuery.kt index f90773bf5..83a1e0bc5 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/SourceQuery.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/queries/SourceQuery.kt @@ -93,7 +93,7 @@ class SourceQuery { val id: Long? = null, val name: String? = null, val lang: String? = null, - @GraphQLDeprecated("replace with contentRating == 3", ReplaceWith("contentRating")) + @GraphQLDeprecated("replace with contentRating == ContentRating.PORNOGRAPHIC", ReplaceWith("contentRating")) val isNsfw: Boolean? = null, val contentRating: ContentRating? = null, ) : HasGetOp { @@ -102,7 +102,7 @@ class SourceQuery { opAnd.eq(id, SourceTable.id) opAnd.eq(name, SourceTable.name) opAnd.eq(lang, SourceTable.lang) - opAnd.andWhere(isNsfw) { if (it) SourceTable.contentRating eq 3 else SourceTable.contentRating neq 3 } + opAnd.andWhere(isNsfw) { if (it) SourceTable.contentRating eq ContentRating.PORNOGRAPHIC.ordinal else SourceTable.contentRating neq ContentRating.PORNOGRAPHIC.ordinal } opAnd.andWhere(contentRating) { SourceTable.contentRating eq it.getValue() } return opAnd.op @@ -113,7 +113,7 @@ class SourceQuery { val id: LongFilter? = null, val name: StringFilter? = null, val lang: StringFilter? = null, - @GraphQLDeprecated("replace with contentRating == 3", ReplaceWith("contentRating")) + @GraphQLDeprecated("replace with contentRating == ContentRating.PORNOGRAPHIC", ReplaceWith("contentRating")) val isNsfw: BooleanFilter? = null, // val contentRating: EnumFilter? = null, override val and: List? = null, diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/types/ExtensionType.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/types/ExtensionType.kt index 68570f7e0..e2bc3ee1a 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/types/ExtensionType.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/types/ExtensionType.kt @@ -60,7 +60,7 @@ class ExtensionType( versionCode = row[ExtensionTable.versionCode].toInt(), versionCodeLong = row[ExtensionTable.versionCode], lang = row[ExtensionTable.lang], - isNsfw = row[ExtensionTable.contentRating] == 3, + isNsfw = row[ExtensionTable.contentRating] == ContentRating.PORNOGRAPHIC.ordinal, contentRating = ContentRating.valueOf(row[ExtensionTable.contentRating]), isInstalled = row[ExtensionTable.isInstalled], hasUpdate = row[ExtensionTable.hasUpdate], diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/types/SourceType.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/types/SourceType.kt index 658d08d58..a815a62ee 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/types/SourceType.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/types/SourceType.kt @@ -63,7 +63,7 @@ class SourceType( iconUrl = Extension.proxyExtensionIconUrl(sourceExtension[ExtensionTable.pkgName]), supportsLatest = catalogueSource.supportsLatest, isConfigurable = catalogueSource is ConfigurableSource, - isNsfw = row[SourceTable.contentRating] == 3, + isNsfw = row[SourceTable.contentRating] == ContentRating.PORNOGRAPHIC.ordinal, displayName = catalogueSource.toString(), homeUrl = runCatching { (catalogueSource as? HttpSource)?.getHomeUrl() }.getOrNull(), baseUrl = runCatching { (catalogueSource as? HttpSource)?.baseUrl }.getOrNull(), diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Source.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Source.kt index 6f1cd1113..aeba5c9a2 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Source.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Source.kt @@ -29,6 +29,7 @@ import suwayomi.tachidesk.manga.impl.extension.Extension.proxyExtensionIconUrl import suwayomi.tachidesk.manga.impl.util.source.GetCatalogueSource.getCatalogueSourceOrNull import suwayomi.tachidesk.manga.impl.util.source.GetCatalogueSource.getCatalogueSourceOrStub import suwayomi.tachidesk.manga.impl.util.source.GetCatalogueSource.unregisterCatalogueSource +import suwayomi.tachidesk.manga.model.dataclass.ContentRating import suwayomi.tachidesk.manga.model.dataclass.SourceDataClass import suwayomi.tachidesk.manga.model.table.ExtensionTable import suwayomi.tachidesk.manga.model.table.SourceMetaTable @@ -52,7 +53,7 @@ object Source { iconUrl = proxyExtensionIconUrl(sourceExtension[ExtensionTable.pkgName]), supportsLatest = catalogueSource.supportsLatest, isConfigurable = catalogueSource is ConfigurableSource, - isNsfw = it[SourceTable.contentRating] == 3, + isNsfw = it[SourceTable.contentRating] == ContentRating.PORNOGRAPHIC.ordinal, displayName = catalogueSource.toString(), baseUrl = runCatching { (catalogueSource as? HttpSource)?.baseUrl }.getOrNull(), ) @@ -73,7 +74,7 @@ object Source { iconUrl = proxyExtensionIconUrl(extension[ExtensionTable.pkgName]), supportsLatest = catalogueSource.supportsLatest, isConfigurable = catalogueSource is ConfigurableSource, - isNsfw = source[SourceTable.contentRating] == 3, + isNsfw = source[SourceTable.contentRating] == ContentRating.PORNOGRAPHIC.ordinal, displayName = catalogueSource.toString(), baseUrl = runCatching { (catalogueSource as? HttpSource)?.baseUrl }.getOrNull(), ) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/Extension.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/Extension.kt index c129d33c6..6ba303171 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/Extension.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/Extension.kt @@ -28,6 +28,7 @@ import org.jetbrains.exposed.v1.jdbc.select 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.types.ContentRating import suwayomi.tachidesk.manga.impl.util.PackageTools import suwayomi.tachidesk.manga.impl.util.PackageTools.EXTENSION_FEATURE import suwayomi.tachidesk.manga.impl.util.PackageTools.LIB_VERSION_MAX @@ -197,7 +198,7 @@ object Extension { it[versionName] = packageInfo.versionName it[versionCode] = packageInfo.versionCode.toLong() it[lang] = extensionLang - it[contentRating] = if (isNsfw) 3 else 0 // todo will change + it[contentRating] = if (isNsfw) ContentRating.PORNOGRAPHIC.ordinal else ContentRating.SAFE.ordinal // todo will change } } @@ -222,7 +223,7 @@ object Extension { it[name] = httpSource.name it[lang] = httpSource.lang it[extension] = extensionId - it[contentRating] = if (isNsfw) 3 else 0 + it[contentRating] = if (isNsfw) ContentRating.PORNOGRAPHIC.ordinal else ContentRating.SAFE.ordinal } logger.debug { "Installed source ${httpSource.name} (${httpSource.lang}) with id:${httpSource.id}" } } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/ExtensionsList.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/ExtensionsList.kt index 1768ff544..20d97c6cf 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/ExtensionsList.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/extension/ExtensionsList.kt @@ -22,6 +22,7 @@ import org.jetbrains.exposed.v1.jdbc.statements.toExecutable import org.jetbrains.exposed.v1.jdbc.transactions.transaction import org.jetbrains.exposed.v1.jdbc.update import suwayomi.tachidesk.manga.impl.extension.Extension.proxyExtensionIconUrl +import suwayomi.tachidesk.manga.model.dataclass.ContentRating import suwayomi.tachidesk.manga.model.dataclass.ExtensionDataClass import suwayomi.tachidesk.manga.model.dataclass.ExtensionInfo import suwayomi.tachidesk.manga.model.table.ExtensionTable @@ -80,7 +81,7 @@ object ExtensionsList { versionName = it[ExtensionTable.versionName], versionCode = it[ExtensionTable.versionCode].toInt(), lang = it[ExtensionTable.lang], - isNsfw = it[ExtensionTable.contentRating] == 3, + isNsfw = it[ExtensionTable.contentRating] == ContentRating.PORNOGRAPHIC.ordinal, installed = it[ExtensionTable.isInstalled], hasUpdate = it[ExtensionTable.hasUpdate], obsolete = it[ExtensionTable.isObsolete], diff --git a/server/src/main/kotlin/suwayomi/tachidesk/server/database/migration/M0057_AddNewExtensionApiFields.kt b/server/src/main/kotlin/suwayomi/tachidesk/server/database/migration/M0057_AddNewExtensionApiFields.kt index bc468dc59..97d078d9f 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/server/database/migration/M0057_AddNewExtensionApiFields.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/server/database/migration/M0057_AddNewExtensionApiFields.kt @@ -8,6 +8,7 @@ package suwayomi.tachidesk.server.database.migration * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ import de.neonew.exposed.migrations.helpers.SQLMigration +import suwayomi.tachidesk.graphql.types.ContentRating import suwayomi.tachidesk.graphql.types.DatabaseType import suwayomi.tachidesk.server.database.migration.helpers.MAYBE_TYPE_PREFIX import suwayomi.tachidesk.server.database.migration.helpers.UNLIMITED_TEXT @@ -43,11 +44,11 @@ class M0057_AddNewExtensionApiFields : SQLMigration() { } ALTER TABLE EXTENSION ADD COLUMN apk_url VARCHAR(2048); ALTER TABLE EXTENSION ADD COLUMN content_rating INTEGER DEFAULT 0; - UPDATE EXTENSION SET content_rating = 3 WHERE is_nsfw = TRUE; + UPDATE EXTENSION SET content_rating = ${ContentRating.PORNOGRAPHIC.ordinal} WHERE is_nsfw = TRUE; ALTER TABLE EXTENSION DROP COLUMN is_nsfw; ALTER TABLE SOURCE ADD COLUMN message $UNLIMITED_TEXT; ALTER TABLE SOURCE ADD COLUMN content_rating INTEGER DEFAULT 0; - UPDATE SOURCE SET content_rating = 3 WHERE is_nsfw = TRUE; + UPDATE SOURCE SET content_rating = ${ContentRating.PORNOGRAPHIC.ordinal} WHERE is_nsfw = TRUE; ALTER TABLE SOURCE DROP COLUMN is_nsfw;