Squashed commit of the following:

commit b7fb903dcab2dbdc55ddd27e9cbd8054f0d5e2a8
Author: SabreCat <sabe@habitica.com>
Date:   Sat Aug 19 19:44:42 2023 -0500

    fix(invites): add missing param

commit 30053cc8b86fc1992d872a068e60f3dd5a456a07
Author: SabreCat <sabe@habitica.com>
Date:   Sat Aug 19 19:06:51 2023 -0500

    fix(party): enforce size limit when using @-names

commit 62dd314cda4165bedbc6b490a8e2f21de87deaf4
Author: SabreCat <sabe@habitica.com>
Date:   Sat Aug 19 19:01:15 2023 -0500

    Revert "Revert "fix(parties): actual 30 not 29""

    This reverts commit 63414a80fe.
This commit is contained in:
SabreCat
2023-08-22 12:25:17 -05:00
parent ba96cd6e24
commit 63376b918e
3 changed files with 10 additions and 6 deletions
@@ -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);
});
+1 -1
View File
@@ -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;
+7 -3
View File
@@ -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 }));
}
}
};