Skip to content

Commit

Permalink
Merge pull request #18 from jutaz/feature/better-filters
Browse files Browse the repository at this point in the history
Feature/better filters
  • Loading branch information
chirag04 committed May 2, 2014
2 parents ea72155 + 059858e commit 1277306
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ module.exports = MailListener;
function MailListener(options) {
this.markSeen = !! options.markSeen;
this.mailbox = options.mailbox || "INBOX";
this.searchFilter = options.searchFilter || "UNSEEN";
if ('string' === typeof options.searchFilter) {
this.searchFilter = [options.searchFilter];
} else {
this.searchFilter = options.searchFilter || ["UNSEEN"];
}
this.fetchUnreadOnStart = !! options.fetchUnreadOnStart;
this.mailParserOptions = options.mailParserOptions || {},
this.imap = new Imap({
Expand Down Expand Up @@ -65,7 +69,7 @@ function imapMail() {

function parseUnread() {
var self = this;
this.imap.search([self.searchFilter], function(err, results) {
this.imap.search(self.searchFilter, function(err, results) {
if (err) {
self.emit('error', err);
} else if (results.length > 0) {
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var mailListener = new MailListener({
tls: true,
tlsOptions: { rejectUnauthorized: false },
mailbox: "INBOX", // mailbox to monitor
searchFilter: "UNSEEN", // the search filter being used after an IDLE notification has been retrieved
searchFilter: ["UNSEEN", "FLAGGED"], // the search filter being used after an IDLE notification has been retrieved
markSeen: true, // all fetched email willbe marked as seen and not fetched next time
fetchUnreadOnStart: true, // use it only if you want to get all unread email on lib start. Default is `false`,
mailParserOptions: {streamAttachments: true} // options to be passed to mailParser lib.
Expand Down

0 comments on commit 1277306

Please sign in to comment.