Recursively calling ExpandDL with easyEws Asynchronously to split groups and groups in groups
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Splits a group and calls the completed function | |
*/ | |
function splitGroupsAndFindExternalsRecursivelyAsync() { | |
if(groups.length == 0) { | |
// if no groups stop | |
completedCallback(); | |
} else { | |
/** @type {string} */ | |
var group = groups.pop(); | |
// call expandGroup to get users | |
easyEws.expandGroup(group, function(groupUsers) { | |
groupUsers.forEach(function(groupUser, index){ | |
if(groupUser.MailboxType() == "PublicDL") { | |
groups.push(groupUser); | |
} else { | |
/** @type {string} */ | |
var emailDomain = getDomain(groupUser.Address()); | |
if(emailDomain != domain) { | |
externals.push(groupUser.Address()); | |
} | |
} | |
}); // groupUsers.forEach | |
splitGroupsAndFindExternalsRecursivelyAsync(); // recursive | |
}, function(error) { | |
console.log(error); | |
// just fail | |
completedCallback(); | |
}); // easyEws.expandGroup | |
} // end-if | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment