Skip to content

Commit

Permalink
getEmails - some more logs added
Browse files Browse the repository at this point in the history
  • Loading branch information
VladLouk committed Sep 12, 2022
1 parent 70f0e37 commit 3879495
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@ class EmailReceiverService(
subject: String? = null,
numRetries: Int = NUM_RETRYES
): List<MimeMessage> {
logger.info("Trying to get email for $to, number of retries left is $numRetries")
logger.info("Trying to get email for: $to, $subject, $numRetries")

for (i in 0 until numRetries) {
if (i != 0) {
Time.sleep(RETRY_TIMEOUT)
}

logger.info("Try #$i to get email for: $to, $subject, $numRetries")

val messages =
try {
getEmails(to = to, subject = subject)
Expand All @@ -62,6 +64,8 @@ class EmailReceiverService(
}
}

logger.warn("No email found for: $to, $subject, $numRetries")

return emptyList()
}

Expand All @@ -72,6 +76,7 @@ class EmailReceiverService(
): List<MimeMessage> {
val email = extractMainEmail(to)
val imapMailReceiver = imapMailReceiver(email)
imapMailReceiver.isShouldMarkMessagesAsRead
val messages = imapMailReceiver.receive().filter { message ->
message is MimeMessage && message.allRecipients.toList().map { it.toString() }.contains(to)
&& if (subject != null) message.subject.toString().contains(subject) else true
Expand Down

0 comments on commit 3879495

Please sign in to comment.