fix user alias API

This commit is contained in:
Girish Ramakrishnan
2016-09-26 00:06:26 -07:00
parent b40e740110
commit d92e99a092
2 changed files with 32 additions and 3 deletions

View File

@@ -588,12 +588,11 @@ function setAliases(userId, aliases, callback) {
if (error && error.reason === DatabaseError.NOT_FOUND) return callback(new UserError(UserError.NOT_FOUND));
if (error) return callback(new UserError(UserError.INTERNAL_ERROR, error));
mailboxdb.setAliasesOf(user.username, aliases, userId, mailboxdb.TYPE_USER, function (error) {
mailboxdb.setAliasesByName(user.username, aliases, function (error) {
if (error && error.reason === DatabaseError.ALREADY_EXISTS) return callback(new UserError(UserError.ALREADY_EXISTS, error.message));
if (error && error.reason === DatabaseError.NOT_FOUND) return callback(new UserError(UserError.NOT_FOUND));
if (error) return callback(new UserError(UserError.INTERNAL_ERROR, error));
callback(null);
});
});
@@ -607,7 +606,7 @@ function getAliases(userId, callback) {
if (error && error.reason === DatabaseError.NOT_FOUND) return callback(new UserError(UserError.NOT_FOUND));
if (error) return callback(new UserError(UserError.INTERNAL_ERROR, error));
mailboxdb.getAliasesOf(user.username, function (error, aliases) {
mailboxdb.getAliasesByName(user.username, function (error, aliases) {
if (error && error.reason === DatabaseError.NOT_FOUND) return callback(new UserError(UserError.NOT_FOUND));
if (error) return callback(new UserError(UserError.INTERNAL_ERROR, error));