Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davecra/dbb53bb0861c9c80e13314833a11a192 to your computer and use it in GitHub Desktop.
Save davecra/dbb53bb0861c9c80e13314833a11a192 to your computer and use it in GitHub Desktop.
Recursively calling ExpandDL with easyEws Asynchronously to split groups and groups in groups
/**
* 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