Improve LDAP mailbox searches to better suit sogo

This commit is contained in:
Johannes Zellner
2020-03-05 22:40:25 -08:00
parent d85eabce02
commit fcee8aa5f3
2 changed files with 56 additions and 26 deletions
+17
View File
@@ -12,6 +12,8 @@ exports = module.exports = {
listMailboxes: listMailboxes,
getLists: getLists,
listAllMailboxes: listAllMailboxes,
get: get,
getMailbox: getMailbox,
getList: getList,
@@ -214,6 +216,21 @@ function listMailboxes(domain, page, perPage, callback) {
});
}
function listAllMailboxes(page, perPage, callback) {
assert.strictEqual(typeof page, 'number');
assert.strictEqual(typeof perPage, 'number');
assert.strictEqual(typeof callback, 'function');
database.query(`SELECT ${MAILBOX_FIELDS} FROM mailboxes WHERE type = ? ORDER BY name LIMIT ${(page-1)*perPage},${perPage}`,
[ exports.TYPE_MAILBOX ], function (error, results) {
if (error) return callback(new BoxError(BoxError.DATABASE_ERROR, error));
results.forEach(function (result) { postProcess(result); });
callback(null, results);
});
}
function getLists(domain, callback) {
assert.strictEqual(typeof domain, 'string');
assert.strictEqual(typeof callback, 'function');