mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-05-06 11:45:48 +02:00
fix: handle client-side acceptAll and rejectAll
This commit is contained in:
@@ -56,36 +56,6 @@ async function isOwner(socket, data) {
|
||||
}
|
||||
}
|
||||
|
||||
SocketGroups.acceptAll = async (socket, data) => {
|
||||
await isOwner(socket, data);
|
||||
await acceptRejectAll(SocketGroups.accept, socket, data);
|
||||
};
|
||||
|
||||
SocketGroups.rejectAll = async (socket, data) => {
|
||||
await isOwner(socket, data);
|
||||
await acceptRejectAll(SocketGroups.reject, socket, data);
|
||||
};
|
||||
|
||||
async function acceptRejectAll(method, socket, data) {
|
||||
if (typeof data.groupName !== 'string') {
|
||||
throw new Error('[[error:invalid-group-name]]');
|
||||
}
|
||||
const users = await groups.getPending(data.groupName);
|
||||
const uids = users.map(u => u.uid);
|
||||
await Promise.all(uids.map(async (uid) => {
|
||||
await method(socket, { groupName: data.groupName, toUid: uid });
|
||||
}));
|
||||
}
|
||||
|
||||
SocketGroups.issueInvite = async (socket, data) => {
|
||||
await isOwner(socket, data);
|
||||
await groups.invite(data.groupName, data.toUid);
|
||||
logGroupEvent(socket, 'group-invite', {
|
||||
groupName: data.groupName,
|
||||
targetUid: data.toUid,
|
||||
});
|
||||
};
|
||||
|
||||
SocketGroups.issueMassInvite = async (socket, data) => {
|
||||
await isOwner(socket, data);
|
||||
if (!data || !data.usernames || !data.groupName) {
|
||||
|
||||
Reference in New Issue
Block a user