|
|
@ -154,17 +154,12 @@ Groups.getOwnersAndMembers = async function (groupName, uid, start, stop) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
let done = false;
|
|
|
|
|
|
|
|
let returnUsers = owners;
|
|
|
|
let returnUsers = owners;
|
|
|
|
let memberStart = start - ownerUids.length + 1;
|
|
|
|
const memberStart = Math.max(0, start - ownerUids.length + 1);
|
|
|
|
let memberStop = memberStart + countToReturn - 1;
|
|
|
|
const memberStop = memberStart + countToReturn;
|
|
|
|
memberStart = Math.max(0, memberStart);
|
|
|
|
|
|
|
|
memberStop = Math.max(0, memberStop);
|
|
|
|
|
|
|
|
async function addMembers(start, stop) {
|
|
|
|
async function addMembers(start, stop) {
|
|
|
|
let batch = await user.getUsersFromSet('group:' + groupName + ':members', uid, start, stop);
|
|
|
|
let batch = await user.getUsersFromSet('group:' + groupName + ':members', uid, start, stop);
|
|
|
|
if (!batch.length) {
|
|
|
|
|
|
|
|
done = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
batch = batch.filter(user => user && user.uid && !ownerUids.includes(user.uid.toString()));
|
|
|
|
batch = batch.filter(user => user && user.uid && !ownerUids.includes(user.uid.toString()));
|
|
|
|
returnUsers = returnUsers.concat(batch);
|
|
|
|
returnUsers = returnUsers.concat(batch);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -172,11 +167,9 @@ Groups.getOwnersAndMembers = async function (groupName, uid, start, stop) {
|
|
|
|
if (stop === -1) {
|
|
|
|
if (stop === -1) {
|
|
|
|
await addMembers(memberStart, -1);
|
|
|
|
await addMembers(memberStart, -1);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
while (returnUsers.length < countToReturn && !done) {
|
|
|
|
while (returnUsers.length < countToReturn) {
|
|
|
|
/* eslint-disable no-await-in-loop */
|
|
|
|
/* eslint-disable no-await-in-loop */
|
|
|
|
await addMembers(memberStart, memberStop);
|
|
|
|
await addMembers(memberStart, memberStop);
|
|
|
|
memberStart += countToReturn;
|
|
|
|
|
|
|
|
memberStop += countToReturn;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|