use of won.bot.framework.eventbot.event.impl.mail.MailReceivedEvent in project webofneeds by researchstudio-sat.
the class MailParserAction method doRun.
protected void doRun(Event event, EventListener executingListener) throws Exception {
if (event instanceof MailReceivedEvent) {
EventBus bus = getEventListenerContext().getEventBus();
MimeMessage message = ((MailReceivedEvent) event).getMessage();
String senderMailAddress = MailContentExtractor.getMailSender(message);
try {
if (mailContentExtractor.isCreateNeedMail(message)) {
processCreateNeedMail(message);
} else if (mailContentExtractor.isCommandMail(message)) {
logger.debug("received a command mail publishing the MailCommand event");
bus.publish(new MailCommandEvent(message));
} else {
logger.warn("unknown mail from user '{}' with subject '{}', no further processing required", senderMailAddress, message.getSubject());
}
} catch (MessagingException me) {
logger.error("Messaging exception occurred while processing MimeMessage: {}", me);
logger.warn("mail from user '{}' with subject '{}' could not be processed", senderMailAddress, message.getSubject());
}
}
}
Aggregations