mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-02 02:21:14 +01:00
feat: #11420, add new GET routes to retrieve pending and invited members of a group, plus accept/reject pending
This commit is contained in:
@@ -123,8 +123,8 @@ Groups.get = async function (groupName, options) {
|
||||
const [groupData, members, pending, invited, isMember, isPending, isInvited, isOwner] = await Promise.all([
|
||||
Groups.getGroupData(groupName),
|
||||
Groups.getOwnersAndMembers(groupName, options.uid, 0, stop),
|
||||
Groups.getUsersFromSet(`group:${groupName}:pending`, ['username', 'userslug', 'picture']),
|
||||
Groups.getUsersFromSet(`group:${groupName}:invited`, ['username', 'userslug', 'picture']),
|
||||
Groups.getPending(groupName),
|
||||
Groups.getInvites(groupName),
|
||||
Groups.isMember(options.uid, groupName),
|
||||
Groups.isPending(options.uid, groupName),
|
||||
Groups.isInvited(options.uid, groupName),
|
||||
|
||||
@@ -9,6 +9,14 @@ const plugins = require('../plugins');
|
||||
const notifications = require('../notifications');
|
||||
|
||||
module.exports = function (Groups) {
|
||||
Groups.getPending = async function (groupName) {
|
||||
return await Groups.getUsersFromSet(`group:${groupName}:pending`, ['username', 'userslug', 'picture']);
|
||||
};
|
||||
|
||||
Groups.getInvites = async function (groupName) {
|
||||
return await Groups.getUsersFromSet(`group:${groupName}:invited`, ['username', 'userslug', 'picture']);
|
||||
};
|
||||
|
||||
Groups.requestMembership = async function (groupName, uid) {
|
||||
await inviteOrRequestMembership(groupName, uid, 'request');
|
||||
const { displayname } = await user.getUserFields(uid, ['username']);
|
||||
@@ -107,11 +115,4 @@ module.exports = function (Groups) {
|
||||
const map = _.zipObject(checkUids, isMembers);
|
||||
return isArray ? uids.map(uid => !!map[uid]) : !!map[uids[0]];
|
||||
}
|
||||
|
||||
Groups.getPending = async function (groupName) {
|
||||
if (!groupName) {
|
||||
return [];
|
||||
}
|
||||
return await db.getSetMembers(`group:${groupName}:pending`);
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user