use of won.bot.framework.eventbot.event.impl.mail.MailCommandEvent in project webofneeds by researchstudio-sat.
the class MailCommandAction method doRun.
@Override
protected void doRun(Event event, EventListener executingListener) throws Exception {
EventListenerContext ctx = getEventListenerContext();
if (event instanceof MailCommandEvent && ctx.getBotContextWrapper() instanceof MailBotContextWrapper) {
MailBotContextWrapper botContextWrapper = (MailBotContextWrapper) ctx.getBotContextWrapper();
MimeMessage message = ((MailCommandEvent) event).getMessage();
String referenceId = MailContentExtractor.getMailReference(message);
WonURI wonUri = botContextWrapper.getWonURIForMailId(referenceId);
// determine if the mail is referring to some other mail/need/connection or not
if (wonUri != null) {
processReferenceMailCommands(message, wonUri);
} else {
processNonReferenceMailCommand(message);
}
}
}
use of won.bot.framework.eventbot.event.impl.mail.MailCommandEvent 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