Commit 1f3ee818 authored by Patricio Bruna's avatar Patricio Bruna

Change method to add DL owner

parent be38a15d
......@@ -30748,7 +30748,7 @@ return /******/ (function(modules) { // webpackBootstrap
module.exports = {
"name": "zimbra-admin-api-js",
"version": "0.2.12",
"version": "0.2.13",
"main": "lib/zimbra-admin-api.js",
"dependencies": {
"crypto-browserify": "^3.11.0",
......@@ -32547,14 +32547,29 @@ return /******/ (function(modules) { // webpackBootstrap
value: function addMembers(members, callback) {
this.api.addDistributionListMember(this.id, members, callback);
}
// addOwner(account_id, callback) {
// const grantee_data = {
// 'type': 'usr',
// 'identifier': account_id
// }
// this.grantRight(grantee_data, this.ownerRights, callback);
// }
}, {
key: 'addOwner',
value: function addOwner(account_id, callback) {
var grantee_data = {
'type': 'usr',
'identifier': account_id
};
this.grantRight(grantee_data, this.ownerRights, callback);
var _this2 = this;
var zimbraACES = this.attrs.zimbraACE || [];
this.api.getAccount(account_id, function (err, data) {
if (err) return callback(err);
var account = data;
var newZimbraACE = account.id + ' usr sendToDistList';
zimbraACES.push(newZimbraACE);
var attrs = { zimbraACE: zimbraACES };
return _this2.api.modifyDistributionList(_this2.id, attrs, callback);
});
}
// return the ID of the owner
......@@ -32608,14 +32623,31 @@ return /******/ (function(modules) { // webpackBootstrap
value: function removeMembers(members, callback) {
this.api.removeDistributionListMember(this.id, members, callback);
}
// removeOwner(account_id, callback) {
// const grantee_data = {
// 'type': 'usr',
// 'identifier': account_id
// }
// this.revokeRight(grantee_data, this.ownerRights, callback);
// }
}, {
key: 'removeOwner',
value: function removeOwner(account_id, callback) {
var grantee_data = {
'type': 'usr',
'identifier': account_id
};
this.revokeRight(grantee_data, this.ownerRights, callback);
var _this3 = this;
if (!this.attrs.zimbraACE) return this;
var zimbraACES = [].concat.apply([], [this.attrs.zimbraACE]);
this.api.getAccount(account_id, function (err, account) {
if (err) return callback(err);
var newACES = zimbraACES.map(function (ace) {
var granteeId = ace.split(/ /)[0];
if (account.id !== granteeId) return ace;
});
var attrs = { zimbraACE: newACES };
return _this3.api.modifyDistributionList(_this3.id, attrs, callback);
});
}
}, {
key: 'rename',
......
{
"name": "zimbra-admin-api-js",
"version": "0.2.12",
"version": "0.2.13",
"main": "lib/zimbra-admin-api.js",
"dependencies": {
"crypto-browserify": "^3.11.0",
......
......@@ -17,12 +17,23 @@ class DistributionList extends Zimbra {
this.api.addDistributionListMember(this.id, members, callback);
}
// addOwner(account_id, callback) {
// const grantee_data = {
// 'type': 'usr',
// 'identifier': account_id
// }
// this.grantRight(grantee_data, this.ownerRights, callback);
// }
addOwner(account_id, callback) {
const grantee_data = {
'type': 'usr',
'identifier': account_id
}
this.grantRight(grantee_data, this.ownerRights, callback);
const zimbraACES = this.attrs.zimbraACE || [];
this.api.getAccount(account_id, (err, data) => {
if (err) return callback(err);
const account = data;
const newZimbraACE = `${account.id} usr sendToDistList`;
zimbraACES.push(newZimbraACE);
const attrs = {zimbraACE: zimbraACES};
return this.api.modifyDistributionList(this.id, attrs, callback);
});
}
// return the ID of the owner
......@@ -69,12 +80,25 @@ class DistributionList extends Zimbra {
this.api.removeDistributionListMember(this.id, members, callback);
}
// removeOwner(account_id, callback) {
// const grantee_data = {
// 'type': 'usr',
// 'identifier': account_id
// }
// this.revokeRight(grantee_data, this.ownerRights, callback);
// }
removeOwner(account_id, callback) {
const grantee_data = {
'type': 'usr',
'identifier': account_id
}
this.revokeRight(grantee_data, this.ownerRights, callback);
if (!this.attrs.zimbraACE) return this;
const zimbraACES = [].concat.apply([], [this.attrs.zimbraACE]);
this.api.getAccount(account_id, (err, account) => {
if (err) return callback(err);
const newACES = zimbraACES.map((ace) =>{
const granteeId = ace.split(/ /)[0];
if (account.id !== granteeId) return ace;
});
const attrs = {zimbraACE: newACES};
return this.api.modifyDistributionList(this.id, attrs, callback);
});
}
rename(new_name, callback) {
......@@ -84,4 +108,4 @@ class DistributionList extends Zimbra {
}
module.exports = DistributionList;
\ No newline at end of file
module.exports = DistributionList;
......@@ -717,7 +717,7 @@
let owner_email = 'domain_admin@customer.dev';
let resource_name = Date.now() + '@customer.dev';
api.createDistributionList(resource_name, {}, function(err, dl){
dl.addOwner(owner_email, function(e, d){
dl.addOwner(owner_email, function(e, dl){
if (e) return console.error(e);
expect(err).to.be.null;
dl.getACLs(function(e, d){
......@@ -735,8 +735,8 @@
let resource_name = Date.now() + '@customer.dev';
api.createDistributionList(resource_name, {}, function(err, dl){
dl.addOwner(owner_email, function(e, d){
dl.removeOwner(owner_email, function(e, d){
dl.getACLs(function(e, d){
d.removeOwner(owner_email, function(e, d){
d.getACLs(function(e, d){
if (e) return console.error(e);
expect(d.length).to.be.equal(0);
done();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment