diff --git a/test/api/v3/integration/groups/POST-groups_invite.test.js b/test/api/v3/integration/groups/POST-groups_invite.test.js index 0001e09e3a..aab4c50a27 100644 --- a/test/api/v3/integration/groups/POST-groups_invite.test.js +++ b/test/api/v3/integration/groups/POST-groups_invite.test.js @@ -7,7 +7,7 @@ import { } from '../../../../helpers/api-integration/v3'; const INVITES_LIMIT = 100; -const PARTY_LIMIT_MEMBERS = 29; +const PARTY_LIMIT_MEMBERS = 30; const MAX_EMAIL_INVITES_BY_USER = 200; describe('Post /groups/:groupId/invite', () => { @@ -571,7 +571,7 @@ describe('Post /groups/:groupId/invite', () => { .to.eventually.be.rejected.and.eql({ code: 400, error: 'BadRequest', - message: t('partyExceedsMembersLimit', { maxMembersParty: PARTY_LIMIT_MEMBERS + 1 }), + message: t('partyExceedsMembersLimit', { maxMembersParty: PARTY_LIMIT_MEMBERS }), }); }).timeout(10000); }); diff --git a/website/common/script/constants.js b/website/common/script/constants.js index b3510378e0..bc569da079 100644 --- a/website/common/script/constants.js +++ b/website/common/script/constants.js @@ -27,7 +27,7 @@ export const SUPPORTED_SOCIAL_NETWORKS = [ export const GUILDS_PER_PAGE = 30; // number of guilds to return per page when using pagination -export const PARTY_LIMIT_MEMBERS = 29; +export const PARTY_LIMIT_MEMBERS = 30; export const MINIMUM_PASSWORD_LENGTH = 8; export const MAXIMUM_PASSWORD_LENGTH = 64; diff --git a/website/server/models/group.js b/website/server/models/group.js index c41aa0320b..6ca51cc955 100644 --- a/website/server/models/group.js +++ b/website/server/models/group.js @@ -414,7 +414,7 @@ function getInviteError (uuids, emails, usernames) { return errorString; } -function getInviteCount (uuids, emails) { +function getInviteCount (uuids, emails, usernames) { let totalInvites = 0; if (uuids) { @@ -425,6 +425,10 @@ function getInviteCount (uuids, emails) { totalInvites += emails.length; } + if (usernames) { + totalInvites += usernames.length; + } + return totalInvites; } @@ -445,7 +449,7 @@ schema.statics.validateInvitations = async function getInvitationErr (invites, r const errorString = getInviteError(uuids, emails, usernames); if (errorString) throw new BadRequest(res.t(errorString)); - const totalInvites = getInviteCount(uuids, emails); + const totalInvites = getInviteCount(uuids, emails, usernames); if (totalInvites > INVITES_LIMIT) { throw new BadRequest(res.t('canOnlyInviteMaxInvites', { maxInvites: INVITES_LIMIT })); } @@ -471,7 +475,7 @@ schema.statics.validateInvitations = async function getInvitationErr (invites, r memberCount += totalInvites; if (memberCount > shared.constants.PARTY_LIMIT_MEMBERS) { - throw new BadRequest(res.t('partyExceedsMembersLimit', { maxMembersParty: shared.constants.PARTY_LIMIT_MEMBERS + 1 })); + throw new BadRequest(res.t('partyExceedsMembersLimit', { maxMembersParty: shared.constants.PARTY_LIMIT_MEMBERS })); } } };