From aa0a9b43b637ffed58bd060d1b713048b7207cca Mon Sep 17 00:00:00 2001 From: Gauthier Roebroeck Date: Wed, 17 Apr 2024 15:48:39 +0800 Subject: [PATCH] fix(api): library restrictions are not properly apply in some cases Closes: #1474 --- .../kotlin/org/gotson/komga/infrastructure/jooq/main/BookDao.kt | 2 +- .../org/gotson/komga/infrastructure/jooq/main/BookDtoDao.kt | 2 +- .../org/gotson/komga/infrastructure/jooq/main/SeriesDao.kt | 2 +- .../org/gotson/komga/infrastructure/jooq/main/SeriesDtoDao.kt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/main/BookDao.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/main/BookDao.kt index 2f2683f04..e7b1c84f9 100644 --- a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/main/BookDao.kt +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/main/BookDao.kt @@ -367,7 +367,7 @@ class BookDao( private fun BookSearch.toCondition(): Condition { var c: Condition = DSL.trueCondition() - if (!libraryIds.isNullOrEmpty()) c = c.and(b.LIBRARY_ID.`in`(libraryIds)) + if (libraryIds != null) c = c.and(b.LIBRARY_ID.`in`(libraryIds)) if (!seriesIds.isNullOrEmpty()) c = c.and(b.SERIES_ID.`in`(seriesIds)) searchTerm?.let { c = c.and(d.TITLE.containsIgnoreCase(it)) } if (!mediaStatus.isNullOrEmpty()) c = c.and(m.STATUS.`in`(mediaStatus)) diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/main/BookDtoDao.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/main/BookDtoDao.kt index 6d02c0bff..f64bda05d 100644 --- a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/main/BookDtoDao.kt +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/main/BookDtoDao.kt @@ -439,7 +439,7 @@ class BookDtoDao( private fun BookSearchWithReadProgress.toCondition(): Condition { var c: Condition = noCondition() - if (!libraryIds.isNullOrEmpty()) c = c.and(b.LIBRARY_ID.`in`(libraryIds)) + if (libraryIds != null) c = c.and(b.LIBRARY_ID.`in`(libraryIds)) if (!seriesIds.isNullOrEmpty()) c = c.and(b.SERIES_ID.`in`(seriesIds)) if (!mediaStatus.isNullOrEmpty()) c = c.and(m.STATUS.`in`(mediaStatus)) if (deleted == true) c = c.and(b.DELETED_DATE.isNotNull) diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/main/SeriesDao.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/main/SeriesDao.kt index 04dfe0054..adb5a9de3 100644 --- a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/main/SeriesDao.kt +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/main/SeriesDao.kt @@ -160,7 +160,7 @@ class SeriesDao( private fun SeriesSearch.toCondition(): Condition { var c: Condition = DSL.trueCondition() - if (!libraryIds.isNullOrEmpty()) c = c.and(s.LIBRARY_ID.`in`(libraryIds)) + if (libraryIds != null) c = c.and(s.LIBRARY_ID.`in`(libraryIds)) if (!collectionIds.isNullOrEmpty()) c = c.and(cs.COLLECTION_ID.`in`(collectionIds)) searchTerm?.let { c = c.and(d.TITLE.containsIgnoreCase(it)) } searchRegex?.let { c = c.and((it.second.toColumn()).likeRegex(it.first)) } diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/main/SeriesDtoDao.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/main/SeriesDtoDao.kt index 39c27bc58..ba082fb5e 100644 --- a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/main/SeriesDtoDao.kt +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/main/SeriesDtoDao.kt @@ -328,7 +328,7 @@ class SeriesDtoDao( private fun SeriesSearchWithReadProgress.toCondition(): Condition { var c = DSL.noCondition() - if (!libraryIds.isNullOrEmpty()) c = c.and(s.LIBRARY_ID.`in`(libraryIds)) + if (libraryIds != null) c = c.and(s.LIBRARY_ID.`in`(libraryIds)) if (!collectionIds.isNullOrEmpty()) c = c.and(cs.COLLECTION_ID.`in`(collectionIds)) searchRegex?.let { c = c.and((it.second.toColumn()).likeRegex(it.first)) } if (!metadataStatus.isNullOrEmpty()) c = c.and(d.STATUS.`in`(metadataStatus))