Added ListenForNewMailsOptions so that there onEmailReceived has to be set

This commit is contained in:
dankito 2024-11-26 03:19:11 +01:00
parent 31ba07d5e9
commit e0b4550cd3
3 changed files with 12 additions and 2 deletions

View File

@ -34,7 +34,7 @@ open class EmailsFetcher(
protected val log by logger() protected val log by logger()
open fun listenForNewEmails(account: EmailAccount, options: FetchEmailsOptions) = runBlocking { open fun listenForNewEmails(account: EmailAccount, options: ListenForNewMailsOptions) = runBlocking {
try { try {
connect(account) { store -> connect(account) { store ->
val folder = store.getFolder(options.emailFolderName) val folder = store.getFolder(options.emailFolderName)

View File

@ -1,6 +1,6 @@
package net.codinux.invoicing.email package net.codinux.invoicing.email
data class FetchEmailsOptions( open class FetchEmailsOptions(
val downloadMessageBody: Boolean = false, val downloadMessageBody: Boolean = false,
val emailFolderName: String = "INBOX", val emailFolderName: String = "INBOX",

View File

@ -0,0 +1,10 @@
package net.codinux.invoicing.email
open class ListenForNewMailsOptions(
downloadMessageBody: Boolean = false,
emailFolderName: String = "INBOX",
onError: ((FetchEmailsError) -> Unit)? = null,
onEmailReceived: (EmailWithInvoice) -> Unit
) : FetchEmailsOptions(downloadMessageBody, emailFolderName, onError, onEmailReceived) {
}