mail: add mailbox count route

This commit is contained in:
Girish Ramakrishnan
2020-07-15 15:33:53 -07:00
parent d429015f83
commit bff4999d27
4 changed files with 108 additions and 71 deletions
+30 -18
View File
@@ -1,31 +1,32 @@
'use strict';
exports = module.exports = {
addMailbox: addMailbox,
addList: addList,
addMailbox,
addList,
updateMailboxOwner: updateMailboxOwner,
updateList: updateList,
del: del,
updateMailboxOwner,
updateList,
del,
listMailboxes: listMailboxes,
getLists: getLists,
getMailboxCount,
listMailboxes,
getLists,
listAllMailboxes: listAllMailboxes,
listAllMailboxes,
get: get,
getMailbox: getMailbox,
getList: getList,
getAlias: getAlias,
get,
getMailbox,
getList,
getAlias,
getAliasesForName: getAliasesForName,
setAliasesForName: setAliasesForName,
getAliasesForName,
setAliasesForName,
getByOwnerId: getByOwnerId,
delByOwnerId: delByOwnerId,
delByDomain: delByDomain,
getByOwnerId,
delByOwnerId,
delByDomain,
updateName: updateName,
updateName,
_clear: clear,
@@ -204,6 +205,17 @@ function getMailbox(name, domain, callback) {
});
}
function getMailboxCount(domain, callback) {
assert.strictEqual(typeof domain, 'string');
assert.strictEqual(typeof callback, 'function');
database.query('SELECT COUNT(*) AS total FROM mailboxes WHERE type = ? AND domain = ?', [ exports.TYPE_MAILBOX, domain ], function (error, results) {
if (error) return callback(new BoxError(BoxError.DATABASE_ERROR, error));
callback(null, results[0].total);
});
}
function listMailboxes(domain, search, page, perPage, callback) {
assert.strictEqual(typeof domain, 'string');
assert(typeof search === 'string' || search === null);