From a40e115c6ae388407be1cb3e15e6a1817c4b8b98 Mon Sep 17 00:00:00 2001 From: Yohann Leon Date: Thu, 16 Apr 2026 21:41:34 +0900 Subject: [PATCH] Fix serialization of KoboProxy objects --- .../komga/interfaces/api/kobo/KoboController.kt | 4 ++-- .../komga/interfaces/api/kobo/dto/BookmarkDto.kt | 6 ++++-- .../komga/interfaces/api/kobo/dto/LocationDto.kt | 2 ++ .../komga/interfaces/api/kobo/dto/ReadingStateDto.kt | 12 ++++++++++-- .../api/kobo/dto/ReadingStateStateUpdateDto.kt | 2 ++ .../komga/interfaces/api/kobo/dto/StatisticsDto.kt | 2 ++ .../komga/interfaces/api/kobo/dto/StatusInfoDto.kt | 4 ++++ 7 files changed, 26 insertions(+), 6 deletions(-) diff --git a/komga/src/main/kotlin/org/gotson/komga/interfaces/api/kobo/KoboController.kt b/komga/src/main/kotlin/org/gotson/komga/interfaces/api/kobo/KoboController.kt index 53eb11a6..3509b70c 100644 --- a/komga/src/main/kotlin/org/gotson/komga/interfaces/api/kobo/KoboController.kt +++ b/komga/src/main/kotlin/org/gotson/komga/interfaces/api/kobo/KoboController.kt @@ -590,8 +590,8 @@ class KoboController( null, locations = R2Locator.Location( - progression = koboUpdate.currentBookmark.contentSourceProgressPercent / 100, - totalProgression = koboUpdate.currentBookmark.progressPercent?.div(100), + progression = koboUpdate.currentBookmark.contentSourceProgressPercent.toFloat() / 100, + totalProgression = koboUpdate.currentBookmark.progressPercent?.toFloat()?.div(100), ), ) }, diff --git a/komga/src/main/kotlin/org/gotson/komga/interfaces/api/kobo/dto/BookmarkDto.kt b/komga/src/main/kotlin/org/gotson/komga/interfaces/api/kobo/dto/BookmarkDto.kt index ffba4abd..b9816277 100644 --- a/komga/src/main/kotlin/org/gotson/komga/interfaces/api/kobo/dto/BookmarkDto.kt +++ b/komga/src/main/kotlin/org/gotson/komga/interfaces/api/kobo/dto/BookmarkDto.kt @@ -1,5 +1,6 @@ package org.gotson.komga.interfaces.api.kobo.dto +import com.fasterxml.jackson.annotation.JsonFormat import com.fasterxml.jackson.annotation.JsonInclude import com.fasterxml.jackson.databind.PropertyNamingStrategies import com.fasterxml.jackson.databind.annotation.JsonNaming @@ -8,16 +9,17 @@ import java.time.ZonedDateTime @JsonNaming(PropertyNamingStrategies.UpperCamelCaseStrategy::class) @JsonInclude(JsonInclude.Include.NON_NULL) data class BookmarkDto( + @JsonFormat(shape = JsonFormat.Shape.STRING) val lastModified: ZonedDateTime, /** * Total progression in the book. * Between 0 and 100. */ - val progressPercent: Float? = null, + val progressPercent: Int? = null, /** * Progression within the resource. * Between 0 and 100. */ - val contentSourceProgressPercent: Float? = null, + val contentSourceProgressPercent: Int? = null, val location: LocationDto? = null, ) diff --git a/komga/src/main/kotlin/org/gotson/komga/interfaces/api/kobo/dto/LocationDto.kt b/komga/src/main/kotlin/org/gotson/komga/interfaces/api/kobo/dto/LocationDto.kt index e93967f6..5a8fcb3a 100644 --- a/komga/src/main/kotlin/org/gotson/komga/interfaces/api/kobo/dto/LocationDto.kt +++ b/komga/src/main/kotlin/org/gotson/komga/interfaces/api/kobo/dto/LocationDto.kt @@ -1,9 +1,11 @@ package org.gotson.komga.interfaces.api.kobo.dto +import com.fasterxml.jackson.annotation.JsonInclude import com.fasterxml.jackson.databind.PropertyNamingStrategies import com.fasterxml.jackson.databind.annotation.JsonNaming @JsonNaming(PropertyNamingStrategies.UpperCamelCaseStrategy::class) +@JsonInclude(JsonInclude.Include.NON_NULL) data class LocationDto( /** * For type=KoboSpan values are in the form "kobo.x.y" diff --git a/komga/src/main/kotlin/org/gotson/komga/interfaces/api/kobo/dto/ReadingStateDto.kt b/komga/src/main/kotlin/org/gotson/komga/interfaces/api/kobo/dto/ReadingStateDto.kt index 1a7ee2d0..2398994f 100644 --- a/komga/src/main/kotlin/org/gotson/komga/interfaces/api/kobo/dto/ReadingStateDto.kt +++ b/komga/src/main/kotlin/org/gotson/komga/interfaces/api/kobo/dto/ReadingStateDto.kt @@ -1,5 +1,7 @@ package org.gotson.komga.interfaces.api.kobo.dto +import com.fasterxml.jackson.annotation.JsonFormat +import com.fasterxml.jackson.annotation.JsonInclude import com.fasterxml.jackson.databind.PropertyNamingStrategies import com.fasterxml.jackson.databind.annotation.JsonNaming import org.gotson.komga.domain.model.ReadProgress @@ -7,14 +9,18 @@ import org.gotson.komga.language.toUTCZoned import java.time.ZonedDateTime @JsonNaming(PropertyNamingStrategies.UpperCamelCaseStrategy::class) +@JsonInclude(JsonInclude.Include.NON_NULL) data class ReadingStateDto( + @JsonFormat(shape = JsonFormat.Shape.STRING) val created: ZonedDateTime? = null, val currentBookmark: BookmarkDto, val entitlementId: String, + @JsonFormat(shape = JsonFormat.Shape.STRING) val lastModified: ZonedDateTime, /** * From CW: apparently always equals to lastModified */ + @JsonFormat(shape = JsonFormat.Shape.STRING) val priorityTimestamp: ZonedDateTime? = null, val statistics: StatisticsDto, val statusInfo: StatusInfoDto, @@ -38,12 +44,14 @@ fun ReadProgress.toDto() = this.locator ?.locations ?.totalProgression - ?.times(100), + ?.times(100) + ?.toInt(), contentSourceProgressPercent = this.locator ?.locations ?.progression - ?.times(100), + ?.times(100) + ?.toInt(), location = this.locator?.let { LocationDto(source = it.href, value = it.koboSpan) }, ), statistics = diff --git a/komga/src/main/kotlin/org/gotson/komga/interfaces/api/kobo/dto/ReadingStateStateUpdateDto.kt b/komga/src/main/kotlin/org/gotson/komga/interfaces/api/kobo/dto/ReadingStateStateUpdateDto.kt index dd9150e7..f19077d1 100644 --- a/komga/src/main/kotlin/org/gotson/komga/interfaces/api/kobo/dto/ReadingStateStateUpdateDto.kt +++ b/komga/src/main/kotlin/org/gotson/komga/interfaces/api/kobo/dto/ReadingStateStateUpdateDto.kt @@ -1,9 +1,11 @@ package org.gotson.komga.interfaces.api.kobo.dto +import com.fasterxml.jackson.annotation.JsonInclude import com.fasterxml.jackson.databind.PropertyNamingStrategies import com.fasterxml.jackson.databind.annotation.JsonNaming @JsonNaming(PropertyNamingStrategies.UpperCamelCaseStrategy::class) +@JsonInclude(JsonInclude.Include.NON_NULL) data class ReadingStateStateUpdateDto( val readingStates: Collection = emptyList(), ) diff --git a/komga/src/main/kotlin/org/gotson/komga/interfaces/api/kobo/dto/StatisticsDto.kt b/komga/src/main/kotlin/org/gotson/komga/interfaces/api/kobo/dto/StatisticsDto.kt index b8b97230..608b02d5 100644 --- a/komga/src/main/kotlin/org/gotson/komga/interfaces/api/kobo/dto/StatisticsDto.kt +++ b/komga/src/main/kotlin/org/gotson/komga/interfaces/api/kobo/dto/StatisticsDto.kt @@ -1,5 +1,6 @@ package org.gotson.komga.interfaces.api.kobo.dto +import com.fasterxml.jackson.annotation.JsonFormat import com.fasterxml.jackson.annotation.JsonInclude import com.fasterxml.jackson.databind.PropertyNamingStrategies import com.fasterxml.jackson.databind.annotation.JsonNaming @@ -8,6 +9,7 @@ import java.time.ZonedDateTime @JsonNaming(PropertyNamingStrategies.UpperCamelCaseStrategy::class) @JsonInclude(JsonInclude.Include.NON_NULL) data class StatisticsDto( + @JsonFormat(shape = JsonFormat.Shape.STRING) val lastModified: ZonedDateTime, val remainingTimeMinutes: Int? = null, val spentReadingMinutes: Int? = null, diff --git a/komga/src/main/kotlin/org/gotson/komga/interfaces/api/kobo/dto/StatusInfoDto.kt b/komga/src/main/kotlin/org/gotson/komga/interfaces/api/kobo/dto/StatusInfoDto.kt index 1a784555..615cee73 100644 --- a/komga/src/main/kotlin/org/gotson/komga/interfaces/api/kobo/dto/StatusInfoDto.kt +++ b/komga/src/main/kotlin/org/gotson/komga/interfaces/api/kobo/dto/StatusInfoDto.kt @@ -1,5 +1,6 @@ package org.gotson.komga.interfaces.api.kobo.dto +import com.fasterxml.jackson.annotation.JsonFormat import com.fasterxml.jackson.annotation.JsonInclude import com.fasterxml.jackson.databind.PropertyNamingStrategies import com.fasterxml.jackson.databind.annotation.JsonNaming @@ -8,9 +9,12 @@ import java.time.ZonedDateTime @JsonNaming(PropertyNamingStrategies.UpperCamelCaseStrategy::class) @JsonInclude(JsonInclude.Include.NON_NULL) data class StatusInfoDto( + @JsonFormat(shape = JsonFormat.Shape.STRING) val lastModified: ZonedDateTime, val status: StatusDto, val timesStartedReading: Int? = null, + @JsonFormat(shape = JsonFormat.Shape.STRING) val lastTimeFinished: ZonedDateTime? = null, + @JsonFormat(shape = JsonFormat.Shape.STRING) val lastTimeStartedReading: ZonedDateTime? = null, )