mirror of
https://github.com/sismics/docs.git
synced 2024-11-22 14:07:55 +01:00
add logs to inbox scanning
This commit is contained in:
parent
808a06b0af
commit
4795d8f48c
@ -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());
|
||||||
|
Loading…
Reference in New Issue
Block a user