diff --git a/komga/src/main/kotlin/org/gotson/komga/interfaces/api/rest/UserController.kt b/komga/src/main/kotlin/org/gotson/komga/interfaces/api/rest/UserController.kt index 06336243..1b5be42d 100644 --- a/komga/src/main/kotlin/org/gotson/komga/interfaces/api/rest/UserController.kt +++ b/komga/src/main/kotlin/org/gotson/komga/interfaces/api/rest/UserController.kt @@ -112,10 +112,12 @@ class UserController( restrictions = ContentRestrictions( ageRestriction = - if (ageRestriction == null || ageRestriction.restriction == AllowExcludeDto.NONE) - null - else - AgeRestriction(ageRestriction.age, ageRestriction.restriction.toDomain()), + ageRestriction.let { + if (it == null || it.restriction == AllowExcludeDto.NONE) + null + else + AgeRestriction(it.age, it.restriction.toDomain()) + }, labelsAllow = labelsAllow ?: emptySet(), labelsExclude = labelsExclude ?: emptySet(), ), diff --git a/komga/src/main/kotlin/org/gotson/komga/interfaces/api/rest/dto/UserDto.kt b/komga/src/main/kotlin/org/gotson/komga/interfaces/api/rest/dto/UserDto.kt index ee425a30..026f9776 100644 --- a/komga/src/main/kotlin/org/gotson/komga/interfaces/api/rest/dto/UserDto.kt +++ b/komga/src/main/kotlin/org/gotson/komga/interfaces/api/rest/dto/UserDto.kt @@ -1,10 +1,12 @@ package org.gotson.komga.interfaces.api.rest.dto +import com.fasterxml.jackson.annotation.JsonInclude import org.gotson.komga.domain.model.AgeRestriction import org.gotson.komga.domain.model.AllowExclude import org.gotson.komga.domain.model.KomgaUser import org.gotson.komga.infrastructure.security.KomgaPrincipal +@JsonInclude(JsonInclude.Include.NON_NULL) data class UserDto( val id: String, val email: String, diff --git a/komga/src/test/kotlin/org/gotson/komga/interfaces/api/rest/UserControllerTest.kt b/komga/src/test/kotlin/org/gotson/komga/interfaces/api/rest/UserControllerTest.kt index 3e39faf0..55d74e1b 100644 --- a/komga/src/test/kotlin/org/gotson/komga/interfaces/api/rest/UserControllerTest.kt +++ b/komga/src/test/kotlin/org/gotson/komga/interfaces/api/rest/UserControllerTest.kt @@ -113,7 +113,7 @@ class UserControllerTest( jsonPath("$.sharedLibrariesId") { doesNotExist() } jsonPath("$.labelsAllow") { isEmpty() } jsonPath("$.labelsExclude") { isEmpty() } - jsonPath("$.ageRestriction") { isEmpty() } + jsonPath("$.ageRestriction") { doesNotExist() } } } }