mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-06-20 19:50:34 +02:00
feat(api): group ownership API route, switch client-side to use API route
This commit is contained in:
@@ -22,16 +22,15 @@ module.exports = function (Groups) {
|
||||
};
|
||||
|
||||
Groups.ownership.grant = async function (toUid, groupName) {
|
||||
// Note: No ownership checking is done here on purpose!
|
||||
await db.setAdd('group:' + groupName + ':owners', toUid);
|
||||
plugins.hooks.fire('action:group.grantOwnership', { uid: toUid, groupName: groupName });
|
||||
};
|
||||
|
||||
Groups.ownership.rescind = async function (toUid, groupName) {
|
||||
// Note: No ownership checking is done here on purpose!
|
||||
// If the owners set only contains one member, error out!
|
||||
// If the owners set only contains one member (and toUid is that member), error out!
|
||||
const numOwners = await db.setCount('group:' + groupName + ':owners');
|
||||
if (numOwners <= 1) {
|
||||
const isOwner = await db.isSortedSetMember(`group:${groupName}:owners`);
|
||||
if (numOwners <= 1 && isOwner) {
|
||||
throw new Error('[[error:group-needs-owner]]');
|
||||
}
|
||||
await db.setRemove('group:' + groupName + ':owners', toUid);
|
||||
|
||||
Reference in New Issue
Block a user