@@ -35,6 +35,7 @@ import org.gotson.komga.interfaces.api.kobo.dto.ChangedEntitlementDto
35
35
import org.gotson.komga.interfaces.api.kobo.dto.KoboBookMetadataDto
36
36
import org.gotson.komga.interfaces.api.kobo.dto.NewEntitlementDto
37
37
import org.gotson.komga.interfaces.api.kobo.dto.ReadingStateDto
38
+ import org.gotson.komga.interfaces.api.kobo.dto.ReadingStateStateUpdateDto
38
39
import org.gotson.komga.interfaces.api.kobo.dto.ReadingStateUpdateResultDto
39
40
import org.gotson.komga.interfaces.api.kobo.dto.RequestResultDto
40
41
import org.gotson.komga.interfaces.api.kobo.dto.ResourcesDto
@@ -382,17 +383,18 @@ class KoboController(
382
383
fun updateState (
383
384
@AuthenticationPrincipal principal : KomgaPrincipal ,
384
385
@PathVariable bookId : String ,
385
- @RequestBody koboUpdate : ReadingStateDto ,
386
+ @RequestBody body : ReadingStateStateUpdateDto ,
386
387
@RequestHeader(name = X_KOBO_DEVICEID , required = false ) koboDeviceId : String = "unknown",
387
388
): ResponseEntity <* > {
388
389
val book =
389
390
bookRepository.findByIdOrNull(bookId)
390
391
? : if (koboProxy.isEnabled())
391
- return koboProxy.proxyCurrentRequest(koboUpdate )
392
+ return koboProxy.proxyCurrentRequest(body )
392
393
else
393
394
throw ResponseStatusException (HttpStatus .NOT_FOUND )
394
395
395
- if (koboUpdate.currentBookmark.location == null ) throw ResponseStatusException (HttpStatus .BAD_REQUEST )
396
+ val koboUpdate = body.readingStates.firstOrNull() ? : throw ResponseStatusException (HttpStatus .BAD_REQUEST )
397
+ if (koboUpdate.currentBookmark.location == null || koboUpdate.currentBookmark.contentSourceProgressPercent == null ) throw ResponseStatusException (HttpStatus .BAD_REQUEST )
396
398
397
399
// convert the Kobo update request to an R2Progression
398
400
val r2Progression =
@@ -411,7 +413,7 @@ class KoboController(
411
413
type = " application/xhtml+xml" ,
412
414
locations =
413
415
R2Locator .Location (
414
- progression = koboUpdate.currentBookmark.progressPercent ,
416
+ progression = koboUpdate.currentBookmark.contentSourceProgressPercent / 100 ,
415
417
),
416
418
),
417
419
)
@@ -433,6 +435,7 @@ class KoboController(
433
435
),
434
436
)
435
437
} catch (e: Exception ) {
438
+ logger.error(e) { " Could not update progression" }
436
439
RequestResultDto (
437
440
requestResult = ResultDto .FAILURE ,
438
441
updateResults =
0 commit comments