Skip to content

Commit

Permalink
[mail] Fix content processing (openhab#16580)
Browse files Browse the repository at this point in the history
Signed-off-by: Jan N. Klug <github@klug.nrw>
  • Loading branch information
J-N-K authored and joni1993 committed Oct 15, 2024
1 parent fa63c7a commit d419d98
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.sun.mail.imap.IMAPInputStream;

/**
* The {@link POP3IMAPHandler} is responsible for handling commands, which are
* sent to one of the channels.
Expand Down Expand Up @@ -184,6 +186,14 @@ private void refresh() {
mimeMultipart.writeTo(os);
contentAsString = os.toString();
}
} else if (rawContent instanceof IMAPInputStream imapInputStream) {
logger.trace("Detected IMAPInputStream message");
try {
contentAsString = new String(imapInputStream.readAllBytes());
} catch (IOException e) {
logger.warn("Could not read from stream: {}", e.getMessage(), e);
continue;
}
} else {
logger.warn(
"Failed to convert mail content from '{}' with subject '{}', to String: {}",
Expand Down

0 comments on commit d419d98

Please sign in to comment.