diff --git a/src/groups/create.js b/src/groups/create.js index eb90b52ba2..9a1f9c3954 100644 --- a/src/groups/create.js +++ b/src/groups/create.js @@ -24,7 +24,7 @@ module.exports = function (Groups) { } const memberCount = data.hasOwnProperty('ownerUid') ? 1 : 0; - const isPrivate = data.hasOwnProperty('private') ? parseInt(data.private, 10) : 1; + const isPrivate = data.hasOwnProperty('private') && data.private !== undefined ? parseInt(data.private, 10) === 1 : true; const groupData = { name: data.name, slug: utils.slugify(data.name), @@ -35,7 +35,7 @@ module.exports = function (Groups) { memberCount: memberCount, hidden: isHidden ? 1 : 0, system: isSystem ? 1 : 0, - private: isPrivate, + private: isPrivate ? 1 : 0, disableJoinRequests: disableJoinRequests, disableLeave: disableLeave, }; diff --git a/test/groups.js b/test/groups.js index c6ca8b1568..3d1627e062 100644 --- a/test/groups.js +++ b/test/groups.js @@ -1161,7 +1161,8 @@ describe('Groups', function () { assert.equal(groupData.name, 'newgroup'); assert.equal(groupData.description, 'group created by admin'); assert.equal(groupData.ownerUid, adminUid); - assert.equal(groupData.private, true); + assert.equal(groupData.private, 1); + assert.equal(groupData.hidden, 0); assert.equal(groupData.memberCount, 1); done(); });