Skip to content

Commit

Permalink
Slettet midlertidlig FORESPOERSEL_SVAR key (#768)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesper-Hustad authored Nov 12, 2024
1 parent 741ddd4 commit 7930cea
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,10 @@ enum class Key(
VEDTAKSPERIODE_ID_LISTE("vedtaksperiode_id_liste"),
VIRKSOMHET("virksomhet"),
VIRKSOMHETER("virksomheter"),
FORESPOERSEL_SVAR("forespoersel_svar"),

// ulik formattering
FORESPOERSEL_ID("forespoerselId"),
FORESPOERSEL_SVAR("forespoersel-svar"),
FORESPOERSEL_SVAR_V2("forespoersel_svar"),
JOURNALPOST_ID("journalpostId"),
ORGNRUNDERENHET("orgnrUnderenhet"),
SPINN_INNTEKTSMELDING_ID("spinnInntektsmeldingId"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,13 @@ import io.micrometer.prometheusmetrics.PrometheusMeterRegistry
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.JsonNull
import no.nav.helsearbeidsgiver.felles.Key
import no.nav.helsearbeidsgiver.felles.json.toJson
import no.nav.helsearbeidsgiver.felles.json.toMap
import no.nav.helsearbeidsgiver.utils.collection.mapValuesNotNull
import no.nav.helsearbeidsgiver.utils.json.parseJson
import no.nav.helsearbeidsgiver.utils.json.toJson

fun MessageContext.publish(vararg messageFields: Pair<Key, JsonElement>): JsonElement = publish(messageFields.toMap())

fun MessageContext.publish(messageFields: Map<Key, JsonElement>): JsonElement =
messageFields
.mapAddTemporaryReplacementKey()
.mapKeys { (key, _) -> key.toString() }
.filterValues { it !is JsonNull }
.toJson()
Expand All @@ -33,16 +29,3 @@ fun MessageContext.publish(messageFields: Map<Key, JsonElement>): JsonElement =
}.toJson()
.also(::publish)
.parseJson()

private fun Map<Key, JsonElement>.mapAddTemporaryReplacementKey(): Map<Key, JsonElement> {
val data = this[Key.DATA]?.toMap().orEmpty()

return if (!data.containsKey(Key.FORESPOERSEL_SVAR)) {
this
} else {
val newDataPair = Key.FORESPOERSEL_SVAR_V2 to data[Key.FORESPOERSEL_SVAR]
val newData = data.plus(newDataPair).mapValuesNotNull { it }

plus(Key.DATA to newData.toJson())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,6 @@ private data class PublishedData(
.shouldNotBeNull()
.toForespoersel()
.toJson(Forespoersel.serializer()),
Key.FORESPOERSEL_SVAR_V2 to
forespoerselSvar.resultat
.shouldNotBeNull()
.toForespoersel()
.toJson(Forespoersel.serializer()),
),
),
)
Expand Down

0 comments on commit 7930cea

Please sign in to comment.