fix: #12446, fix groups.ownership.rescind

This commit is contained in:
Barış Soner Uşaklı
2024-03-26 18:50:25 -04:00
parent 0171e73a78
commit ed41e416e2

View File

@@ -28,8 +28,10 @@ module.exports = function (Groups) {
Groups.ownership.rescind = async function (toUid, groupName) {
// If the owners set only contains one member (and toUid is that member), error out!
const numOwners = await db.setCount(`group:${groupName}:owners`);
const isOwner = await db.isSortedSetMember(`group:${groupName}:owners`);
const [numOwners, isOwner] = await Promise.all([
db.setCount(`group:${groupName}:owners`),
db.isSetMember(`group:${groupName}:owners`, toUid),
]);
if (numOwners <= 1 && isOwner) {
throw new Error('[[error:group-needs-owner]]');
}