mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: #12446, fix groups.ownership.rescind
This commit is contained in:
@@ -28,8 +28,10 @@ module.exports = function (Groups) {
|
|||||||
|
|
||||||
Groups.ownership.rescind = async function (toUid, groupName) {
|
Groups.ownership.rescind = async function (toUid, groupName) {
|
||||||
// If the owners set only contains one member (and toUid is that 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`);
|
const [numOwners, isOwner] = await Promise.all([
|
||||||
const isOwner = await db.isSortedSetMember(`group:${groupName}:owners`);
|
db.setCount(`group:${groupName}:owners`),
|
||||||
|
db.isSetMember(`group:${groupName}:owners`, toUid),
|
||||||
|
]);
|
||||||
if (numOwners <= 1 && isOwner) {
|
if (numOwners <= 1 && isOwner) {
|
||||||
throw new Error('[[error:group-needs-owner]]');
|
throw new Error('[[error:group-needs-owner]]');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user