mail: Add pagination to lists API

Fixes #712
This commit is contained in:
Girish Ramakrishnan
2020-07-05 10:36:17 -07:00
parent f9115f902a
commit 725a19e5b5
4 changed files with 16 additions and 5 deletions
+4 -2
View File
@@ -234,11 +234,13 @@ function listAllMailboxes(page, perPage, callback) {
});
}
function getLists(domain, callback) {
function getLists(domain, page, perPage, callback) {
assert.strictEqual(typeof domain, 'string');
assert.strictEqual(typeof page, 'number');
assert.strictEqual(typeof perPage, 'number');
assert.strictEqual(typeof callback, 'function');
database.query('SELECT ' + MAILBOX_FIELDS + ' FROM mailboxes WHERE type = ? AND domain = ?',
database.query(`SELECT ${MAILBOX_FIELDS} FROM mailboxes WHERE type = ? AND domain = ? ORDER BY name LIMIT ${(page-1)*perPage},${perPage}`,
[ exports.TYPE_LIST, domain ], function (error, results) {
if (error) return callback(new BoxError(BoxError.DATABASE_ERROR, error));