feat: option to restrict group leaving, closes #7770

This commit is contained in:
Julian Lam
2019-09-05 12:01:32 -04:00
parent 4588a4fdcf
commit 1796b65d34
10 changed files with 52 additions and 10 deletions

View File

@@ -43,7 +43,7 @@ SocketGroups.join = async (socket, data) => {
});
if (results.groupData.private && results.groupData.disableJoinRequests) {
throw new Error('[[error:join-requests-disabled]]');
throw new Error('[[error:group-join-disabled]]');
}
if (!results.groupData.private || results.isAdmin) {
@@ -68,6 +68,11 @@ SocketGroups.leave = async (socket, data) => {
throw new Error('[[error:cant-remove-self-as-admin]]');
}
const groupData = await groups.getGroupData(data.groupName);
if (groupData.disableLeave) {
throw new Error('[[error:group-leave-disabled]]');
}
await groups.leave(data.groupName, socket.uid);
logGroupEvent(socket, 'group-leave', {
groupName: data.groupName,