Add routes to change the mailbox and list owner

This commit is contained in:
Girish Ramakrishnan
2018-04-03 14:12:43 -07:00
parent a1f4a4d614
commit f8a731f63a
4 changed files with 78 additions and 0 deletions

View File

@@ -2,6 +2,7 @@
exports = module.exports = {
add: add,
update: update,
del: del,
listAliases: listAliases,
@@ -50,6 +51,21 @@ function add(name, domain, ownerId, ownerType, callback) {
});
}
function update(name, domain, ownerId, ownerType, callback) {
assert.strictEqual(typeof name, 'string');
assert.strictEqual(typeof domain, 'string');
assert.strictEqual(typeof ownerId, 'string');
assert.strictEqual(typeof ownerType, 'string');
assert.strictEqual(typeof callback, 'function');
database.query('UPDATE mailboxes SET ownerId = ? WHERE name = ? AND domain = ? AND ownerType = ?', [ ownerId, name, domain, ownerType ], function (error, result) {
if (error) return callback(new DatabaseError(DatabaseError.INTERNAL_ERROR, error));
if (result.affectedRows === 0) return callback(new DatabaseError(DatabaseError.NOT_FOUND));
callback(null);
});
}
function clear(callback) {
assert.strictEqual(typeof callback, 'function');