diff --git a/src/main/kotlin/no/nav/syfo/application/SendDialogmeldingArenaCronjob.kt b/src/main/kotlin/no/nav/syfo/application/SendDialogmeldingArenaCronjob.kt index fe98cbf..55bc5c5 100644 --- a/src/main/kotlin/no/nav/syfo/application/SendDialogmeldingArenaCronjob.kt +++ b/src/main/kotlin/no/nav/syfo/application/SendDialogmeldingArenaCronjob.kt @@ -32,14 +32,15 @@ class SendDialogmeldingArenaCronjob( val unpublishedArenaMeldinger = database.getUnpublishedArenaMeldinger() unpublishedArenaMeldinger.forEach { (dialogmeldingId, fellesformat, msgId) -> try { - val sendToArena = !arenaDialogmeldingService.isMeldingStoredInBehandlerdialog(msgId) + val fellesformatXml = safeUnmarshal(fellesformat) + val receivedDialogmelding = ReceivedDialogmelding.create( + dialogmeldingId = dialogmeldingId, + fellesformat = fellesformatXml, + inputMessageText = fellesformat, + ) + val sendToArena = !arenaDialogmeldingService.isMeldingStoredInBehandlerdialog(msgId) && + receivedDialogmelding.dialogmelding.innkallingMoterespons == null if (sendToArena) { - val fellesformatXml = safeUnmarshal(fellesformat) - val receivedDialogmelding = ReceivedDialogmelding.create( - dialogmeldingId = dialogmeldingId, - fellesformat = fellesformatXml, - inputMessageText = fellesformat, - ) arenaDialogmeldingService.sendArenaDialogmeldingToMQ( receivedDialogmelding = receivedDialogmelding, fellesformatXml = fellesformatXml diff --git a/src/test/kotlin/no/nav/syfo/dialogmelding/SendDialogmeldingArenaCronjobSpek.kt b/src/test/kotlin/no/nav/syfo/dialogmelding/SendDialogmeldingArenaCronjobSpek.kt index 6e2ca76..983c82f 100644 --- a/src/test/kotlin/no/nav/syfo/dialogmelding/SendDialogmeldingArenaCronjobSpek.kt +++ b/src/test/kotlin/no/nav/syfo/dialogmelding/SendDialogmeldingArenaCronjobSpek.kt @@ -239,6 +239,31 @@ class SendDialogmeldingArenaCronjobSpek : Spek({ } verify(exactly = 0) { mqSender.sendArena(any()) } } + it("Does not send when melding is svar på dialogmøteinnkalling") { + val fellesformatMeldingSvarMoteinnkalling = + getFileAsString("src/test/resources/dialogmelding_dialog_svar_innkalling_dialogmote.xml") + val fellesformatXmlMeldingInBehandlerdialog = safeUnmarshal(fellesformatMeldingSvarMoteinnkalling) + val receivedDialogmeldingInBehandlerdialog = ReceivedDialogmelding.create( + dialogmeldingId = UUID.randomUUID().toString(), + fellesformat = fellesformatXmlMeldingInBehandlerdialog, + inputMessageText = fellesformatMeldingSvarMoteinnkalling, + ) + val dialogmeldingId = createDialogmeldingOpplysning(receivedDialogmeldingInBehandlerdialog) + database.lagreSendtKafka(dialogmeldingId) + database.lagreSendtApprec(dialogmeldingId) + database.updateSendtApprec( + dialogmeldingId = dialogmeldingId, + timestamp = Timestamp.valueOf(LocalDateTime.now().minusMinutes(11)), + ) + + runBlocking { + val result = sendDialogmeldingArenaCronjob.runJob() + + result.updated shouldBeEqualTo 1 + result.failed shouldBeEqualTo 0 + } + verify(exactly = 0) { mqSender.sendArena(any()) } + } it("Does not process dialogmelding when already checked whether it should be sent to arena") { val fellesformatMeldingInBehandlerdialog =