Skip to content

Instantly share code, notes, and snippets.

@lperrin
Created March 8, 2013 09:34
Show Gist options
  • Save lperrin/5115300 to your computer and use it in GitHub Desktop.
Save lperrin/5115300 to your computer and use it in GitHub Desktop.
exports.fetchConversationDetail2 = function (req, res) {
var contact = req.params.contact;
console.log(contact);
async.auto({
search_from: function (done) {
imap.search([['HEADER', 'FROM', contact]], done);
},
search_to: function (done) {
sentImap.search([['HEADER', 'TO', contact]], done);
},
fetch_from: ['search_from', function (done, results) {
console.log('from: ' + results.search_from);
fetchEmails(results.search_from, {}, [{headers: ['subject']}, {id: 1, body: true}], imap, done);
}],
fetch_to: ['search_to', function (done, results) {
console.log('to: ' + results.search_to);
fetchEmails(results.search_to, {}, [{headers: ['subject']}, {id: 1, body: true}], sentImap, done);
}]
}, function (err, results) {
console.log(results.fetch_from);
console.log(results.fetch_to);
res.send({status: 'ok'});
});;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment