diff --git a/src/api/groups.js b/src/api/groups.js index ad8f3c4f51..58927d9f73 100644 --- a/src/api/groups.js +++ b/src/api/groups.js @@ -98,7 +98,7 @@ groupsAPI.join = async function (caller, data) { return; } - if (isSelf && groupData.private && groupData.disableJoinRequests) { + if (!isCallerAdmin && isSelf && groupData.private && groupData.disableJoinRequests) { throw new Error('[[error:group-join-disabled]]'); } diff --git a/test/groups.js b/test/groups.js index 87d6c8fb69..255a4d52eb 100644 --- a/test/groups.js +++ b/test/groups.js @@ -723,6 +723,12 @@ describe('Groups', () => { } meta.config.allowPrivateGroups = oldValue; }); + + it('should allow admins to join private groups', async () => { + const groupsAPI = require('../src/api/groups'); + await groupsAPI.join({ uid: adminUid }, { uid: adminUid, slug: 'global-moderators' }); + assert(await Groups.isMember(adminUid, 'Global Moderators')); + }); }); describe('.leave()', () => {