Skip to content

Commit

Permalink
Mail check aksepterer ikke-eksisterende folder
Browse files Browse the repository at this point in the history
  • Loading branch information
thburnett committed Oct 10, 2024
1 parent cbe7b0f commit 2118fce
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions smtp-transport/src/main/kotlin/no/nav/emottak/smtp/Routes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,24 @@ import java.time.Instant
import kotlin.time.toKotlinDuration

fun Route.mailCheck(): Route = get("/mail/check") {
val report = mutableMapOf<String, String>()
incomingStore.getFolder("INBOX").use {
it.open(Folder.READ_ONLY)
report["incomingStore Inbox"] = it.messageCount.toString()
}

bccStore.getFolder("INBOX").use {
it.open(Folder.READ_ONLY)
report["bccStore Inbox"] = it.messageCount.toString()
}

bccStore.getFolder("testdata").use {
it.open(Folder.READ_ONLY)
report["bccStore testdata"] = it.messageCount.toString()
}
val report = mapOf(
"incomingStore Inbox" to incomingStore.getFolder("INBOX").getMessageCountAsString(),
"bccStore Inbox" to bccStore.getFolder("INBOX").getMessageCountAsString(),
"bccStore testdata" to bccStore.getFolder("testdata").getMessageCountAsString()
)
call.respond(HttpStatusCode.OK, report)
}

fun Folder.getMessageCountAsString(): String =
if (this.exists()) {
this.use {
it.open(Folder.READ_ONLY)
it.messageCount.toString()
}
} else {
"Folder does not exist"
}

fun Route.mailRead(): Route = get("/mail/read") {
val httpClient = HttpClient(CIO)
call.respond(HttpStatusCode.OK, "Meldingslesing startet ...")
Expand Down

0 comments on commit 2118fce

Please sign in to comment.