add logs to inbox scanning

This commit is contained in:
Benjamin Gamard 2018-03-01 16:28:57 +01:00
parent 808a06b0af
commit 4795d8f48c

View File

@ -69,21 +69,19 @@ public class InboxService extends AbstractScheduledService {
return; return;
} }
log.info("Synchronizing IMAP inbox...");
Folder inbox = null; Folder inbox = null;
lastSyncError = null; lastSyncError = null;
lastSyncDate = new Date(); lastSyncDate = new Date();
lastSyncMessageCount = 0; lastSyncMessageCount = 0;
try { try {
inbox = openInbox(); inbox = openInbox();
int count = inbox.getMessageCount(); Message[] messages = inbox.search(new FlagTerm(new Flags(Flags.Flag.SEEN), false));
Message[] messages = inbox.getMessages(1, count); log.info(messages.length + " messages found, importing...");
for (Message message : messages) { for (Message message : messages) {
if (!message.getFlags().contains(Flags.Flag.SEEN)) {
importMessage(message); importMessage(message);
lastSyncMessageCount++; lastSyncMessageCount++;
} }
}
} catch (Exception e) { } catch (Exception e) {
log.error("Error synching the inbox", e); log.error("Error synching the inbox", e);
lastSyncError = e.getMessage(); lastSyncError = e.getMessage();
@ -172,6 +170,8 @@ public class InboxService extends AbstractScheduledService {
* @throws Exception e * @throws Exception e
*/ */
private void importMessage(Message message) throws Exception { private void importMessage(Message message) throws Exception {
log.info("Importing message: " + message.getSubject());
// Parse the mail // Parse the mail
EmailUtil.MailContent mailContent = new EmailUtil.MailContent(); EmailUtil.MailContent mailContent = new EmailUtil.MailContent();
mailContent.setSubject(message.getSubject()); mailContent.setSubject(message.getSubject());