mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-11 08:25:46 +01:00
feat(api): group ownership API route, switch client-side to use API route
This commit is contained in:
@@ -177,6 +177,28 @@ groupsAPI.leave = async function (caller, data) {
|
||||
});
|
||||
};
|
||||
|
||||
groupsAPI.grant = async (caller, data) => {
|
||||
const groupName = await groups.getGroupNameByGroupSlug(data.slug);
|
||||
await isOwner(caller, groupName);
|
||||
|
||||
await groups.ownership.grant(data.uid, groupName);
|
||||
logGroupEvent(caller, 'group-owner-grant', {
|
||||
groupName: groupName,
|
||||
targetUid: data.uid,
|
||||
});
|
||||
};
|
||||
|
||||
groupsAPI.rescind = async (caller, data) => {
|
||||
const groupName = await groups.getGroupNameByGroupSlug(data.slug);
|
||||
await isOwner(caller, groupName);
|
||||
|
||||
await groups.ownership.rescind(data.uid, groupName);
|
||||
logGroupEvent(caller, 'group-owner-rescind', {
|
||||
groupName: groupName,
|
||||
targetUid: data.uid,
|
||||
});
|
||||
};
|
||||
|
||||
async function isOwner(caller, groupName) {
|
||||
if (typeof groupName !== 'string') {
|
||||
throw new Error('[[error:invalid-group-name]]');
|
||||
|
||||
Reference in New Issue
Block a user