Skip to content

Commit

Permalink
Erstatt key i melding for kontekst-ID (kalt 'uuid') (#777)
Browse files Browse the repository at this point in the history
* Erstatt key i melding for kontekst-ID (kalt 'uuid')

* Fjern duplisert kontekst-ID-nøkkel
  • Loading branch information
bjerga authored Nov 19, 2024
1 parent 8ae3f53 commit f37e44d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
5 changes: 3 additions & 2 deletions felles/src/main/kotlin/no/nav/helsearbeidsgiver/felles/Key.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ enum class Key(
INNTEKT("inntekt"),
INNTEKTSDATO("inntektsdato"),
INNTEKTSMELDING("inntektsmelding"),
KONTEKST_ID("kontekst_id"),
LAGRET_INNTEKTSMELDING("lagret_inntektsmelding"),
OPPGAVE_ID("oppgave_id"),
ORGNR_UNDERENHETER("orgnr_underenheter"),
Expand All @@ -45,7 +44,6 @@ enum class Key(
SKJEMA_INNTEKTSMELDING("skjema_inntektsmelding"),
SYKMELDT("sykmeldt"),
TILGANG("tilgang"),
UUID("uuid"),
VEDTAKSPERIODE_ID_LISTE("vedtaksperiode_id_liste"),
VIRKSOMHET("virksomhet"),
VIRKSOMHETER("virksomheter"),
Expand All @@ -55,6 +53,9 @@ enum class Key(
// ulik formattering
ORGNRUNDERENHET("orgnrUnderenhet"),
SPINN_INNTEKTSMELDING_ID("spinnInntektsmeldingId"),

// TODO erstatt med KONTEKST_ID
UUID("kontekst_id"),
;

override fun toString(): String = str
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,14 @@ 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.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
.let { root ->
root
.plus(Key.KONTEKST_ID to root[Key.UUID])
.mapValuesNotNull { it }
}.mapKeys { (key, _) -> key.toString() }
.mapKeys { (key, _) -> key.toString() }
.filterValues { it !is JsonNull }
.toJson()
.toString()
Expand Down

0 comments on commit f37e44d

Please sign in to comment.