[PM-14526] Add JsonNames annotation to SyncResponseJson (#4269)

Co-authored-by: David Perez <david@livefront.com>
This commit is contained in:
Patrick Honkonen 2024-11-11 12:56:27 -05:00 committed by GitHub
parent 2c40a7f105
commit c5293715e1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 2 deletions

View file

@ -17,7 +17,6 @@ import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.merge import kotlinx.coroutines.flow.merge
@ -125,7 +124,6 @@ class VaultDiskSourceImpl(
override fun getDomains(userId: String): Flow<SyncResponseJson.Domains?> = override fun getDomains(userId: String): Flow<SyncResponseJson.Domains?> =
domainsDao domainsDao
.getDomains(userId) .getDomains(userId)
.filterNotNull()
.map { entity -> .map { entity ->
withContext(dispatcherManager.default) { withContext(dispatcherManager.default) {
entity?.domainsJson?.let { json.decodeFromString<SyncResponseJson.Domains>(it) } entity?.domainsJson?.let { json.decodeFromString<SyncResponseJson.Domains>(it) }

View file

@ -1,8 +1,10 @@
package com.x8bit.bitwarden.data.vault.datasource.network.model package com.x8bit.bitwarden.data.vault.datasource.network.model
import kotlinx.serialization.Contextual import kotlinx.serialization.Contextual
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.SerialName import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JsonNames
import kotlinx.serialization.json.JsonObject import kotlinx.serialization.json.JsonObject
import java.time.ZonedDateTime import java.time.ZonedDateTime
@ -21,6 +23,7 @@ private const val DEFAULT_FIDO_2_KEY_CURVE = "P-256"
* @property domains A domains object associated with the vault data. * @property domains A domains object associated with the vault data.
* @property sends A list of send objects associated with the vault data (nullable). * @property sends A list of send objects associated with the vault data (nullable).
*/ */
@OptIn(ExperimentalSerializationApi::class)
@Serializable @Serializable
data class SyncResponseJson( data class SyncResponseJson(
@SerialName("folders") @SerialName("folders")
@ -30,6 +33,7 @@ data class SyncResponseJson(
val collections: List<Collection>?, val collections: List<Collection>?,
@SerialName("profile") @SerialName("profile")
@JsonNames("Profile")
val profile: Profile, val profile: Profile,
@SerialName("ciphers") @SerialName("ciphers")
@ -39,6 +43,7 @@ data class SyncResponseJson(
val policies: List<Policy>?, val policies: List<Policy>?,
@SerialName("domains") @SerialName("domains")
@JsonNames("Domains")
val domains: Domains?, val domains: Domains?,
@SerialName("sends") @SerialName("sends")