fix(api): omit UserDto.ageRestriction instead of returning null

Closes: 2296
This commit is contained in:
James Ward 2026-04-23 02:34:05 -04:00 committed by GitHub
parent bb60a797e8
commit e3a8cc6b01
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 5 deletions

View file

@ -112,10 +112,12 @@ class UserController(
restrictions = restrictions =
ContentRestrictions( ContentRestrictions(
ageRestriction = ageRestriction =
if (ageRestriction == null || ageRestriction.restriction == AllowExcludeDto.NONE) ageRestriction.let {
if (it == null || it.restriction == AllowExcludeDto.NONE)
null null
else else
AgeRestriction(ageRestriction.age, ageRestriction.restriction.toDomain()), AgeRestriction(it.age, it.restriction.toDomain())
},
labelsAllow = labelsAllow ?: emptySet(), labelsAllow = labelsAllow ?: emptySet(),
labelsExclude = labelsExclude ?: emptySet(), labelsExclude = labelsExclude ?: emptySet(),
), ),

View file

@ -1,10 +1,12 @@
package org.gotson.komga.interfaces.api.rest.dto 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.AgeRestriction
import org.gotson.komga.domain.model.AllowExclude import org.gotson.komga.domain.model.AllowExclude
import org.gotson.komga.domain.model.KomgaUser import org.gotson.komga.domain.model.KomgaUser
import org.gotson.komga.infrastructure.security.KomgaPrincipal import org.gotson.komga.infrastructure.security.KomgaPrincipal
@JsonInclude(JsonInclude.Include.NON_NULL)
data class UserDto( data class UserDto(
val id: String, val id: String,
val email: String, val email: String,

View file

@ -113,7 +113,7 @@ class UserControllerTest(
jsonPath("$.sharedLibrariesId") { doesNotExist() } jsonPath("$.sharedLibrariesId") { doesNotExist() }
jsonPath("$.labelsAllow") { isEmpty() } jsonPath("$.labelsAllow") { isEmpty() }
jsonPath("$.labelsExclude") { isEmpty() } jsonPath("$.labelsExclude") { isEmpty() }
jsonPath("$.ageRestriction") { isEmpty() } jsonPath("$.ageRestriction") { doesNotExist() }
} }
} }
} }