Delete group after removing it from the group list

pull/5276/head
Timon Engelke 2021-11-13 00:15:31 +01:00 committed by Richard Hansen
parent 09c9e32d72
commit 3070cee9ca
1 changed files with 10 additions and 12 deletions

View File

@ -55,9 +55,8 @@ exports.deleteGroup = async (groupID) => {
// loop through all sessions and delete them (in parallel)
await Promise.all(Object.keys(sessions).map((session) => sessionManager.deleteSession(session)));
// remove group and group2sessions entry
// remove group2sessions entry
await db.remove(`group2sessions:${groupID}`);
await db.remove(`group:${groupID}`);
// unlist the group
let groups = await exports.listAllGroups();
@ -65,19 +64,18 @@ exports.deleteGroup = async (groupID) => {
const index = groups.indexOf(groupID);
if (index === -1) {
// it's not listed
if (index !== -1) {
// remove from the list
groups.splice(index, 1);
return;
// regenerate group list
const newGroups = {};
groups.forEach((group) => newGroups[group] = 1);
await db.set('groups', newGroups);
}
// remove from the list
groups.splice(index, 1);
// regenerate group list
const newGroups = {};
groups.forEach((group) => newGroups[group] = 1);
await db.set('groups', newGroups);
// remove group entry
await db.remove(`group:${groupID}`);
};
exports.doesGroupExist = async (groupID) => {