From d6d8de41dc6af1cf2b2f555674fefc955409db39 Mon Sep 17 00:00:00 2001 From: Mike Date: Mon, 28 Apr 2025 16:43:58 +0200 Subject: [PATCH] Feat: Increase invite limit from 10 to 200 (#4618) --- .../server/modules/serverinvites/domain/constants.ts | 1 + .../serverinvites/graph/resolvers/serverInvites.ts | 9 +++++---- packages/server/modules/workspaces/domain/constants.ts | 1 + .../modules/workspaces/graph/resolvers/workspaces.ts | 9 +++++---- .../workspaces/tests/integration/invites.graph.spec.ts | 6 +++--- 5 files changed, 15 insertions(+), 11 deletions(-) create mode 100644 packages/server/modules/workspaces/domain/constants.ts diff --git a/packages/server/modules/serverinvites/domain/constants.ts b/packages/server/modules/serverinvites/domain/constants.ts index 8c0d9850b..9d1f91202 100644 --- a/packages/server/modules/serverinvites/domain/constants.ts +++ b/packages/server/modules/serverinvites/domain/constants.ts @@ -1,2 +1,3 @@ export const ProjectInviteResourceType = 'project' export const ServerInviteResourceType = 'server' +export const ServerInviteLimit = 200 diff --git a/packages/server/modules/serverinvites/graph/resolvers/serverInvites.ts b/packages/server/modules/serverinvites/graph/resolvers/serverInvites.ts index 00794b106..4f69ab782 100644 --- a/packages/server/modules/serverinvites/graph/resolvers/serverInvites.ts +++ b/packages/server/modules/serverinvites/graph/resolvers/serverInvites.ts @@ -53,6 +53,7 @@ import { } from '@/modules/serverinvites/domain/types' import { ProjectInviteResourceType, + ServerInviteLimit, ServerInviteResourceType } from '@/modules/serverinvites/domain/constants' import { @@ -263,9 +264,9 @@ export = { const { input: paramsArray } = args const inviteCount = paramsArray.length - if (inviteCount > 10 && context.role !== Roles.Server.Admin) { + if (inviteCount > ServerInviteLimit && context.role !== Roles.Server.Admin) { throw new InviteCreateValidationError( - 'Maximum 10 invites can be sent at once by non admins' + `Maximum ${ServerInviteLimit} invites can be sent at once by non admins` ) } const logger = context.log.child({ @@ -554,9 +555,9 @@ export = { const { projectId } = args const inviteCount = args.input.length - if (inviteCount > 10 && ctx.role !== Roles.Server.Admin) { + if (inviteCount > ServerInviteLimit && ctx.role !== Roles.Server.Admin) { throw new InviteCreateValidationError( - 'Maximum 10 invites can be sent at once by non admins' + `Maximum ${ServerInviteLimit} invites can be sent at once by non admins` ) } diff --git a/packages/server/modules/workspaces/domain/constants.ts b/packages/server/modules/workspaces/domain/constants.ts new file mode 100644 index 000000000..7eb6ab7ae --- /dev/null +++ b/packages/server/modules/workspaces/domain/constants.ts @@ -0,0 +1 @@ +export const WorkspaceInvitesLimit = 200 diff --git a/packages/server/modules/workspaces/graph/resolvers/workspaces.ts b/packages/server/modules/workspaces/graph/resolvers/workspaces.ts index cfba612ce..687085615 100644 --- a/packages/server/modules/workspaces/graph/resolvers/workspaces.ts +++ b/packages/server/modules/workspaces/graph/resolvers/workspaces.ts @@ -218,6 +218,7 @@ import { throwIfAuthNotOk } from '@/modules/shared/helpers/errorHelper' import { withOperationLogging } from '@/observability/domain/businessLogging' +import { WorkspaceInvitesLimit } from '@/modules/workspaces/domain/constants' const eventBus = getEventBus() const getServerInfo = getServerInfoFactory({ db }) @@ -395,9 +396,9 @@ export = FF_WORKSPACES_MODULE_ENABLED const { projectId } = args const inviteCount = args.inputs.length - if (inviteCount > 10 && ctx.role !== Roles.Server.Admin) { + if (inviteCount > WorkspaceInvitesLimit && ctx.role !== Roles.Server.Admin) { throw new InviteCreateValidationError( - 'Maximum 10 invites can be sent at once by non admins' + `Maximum ${WorkspaceInvitesLimit} invites can be sent at once by non admins` ) } @@ -1168,9 +1169,9 @@ export = FF_WORKSPACES_MODULE_ENABLED const { workspaceId } = args const inviteCount = args.input.length - if (inviteCount > 10 && ctx.role !== Roles.Server.Admin) { + if (inviteCount > WorkspaceInvitesLimit && ctx.role !== Roles.Server.Admin) { throw new InviteCreateValidationError( - 'Maximum 10 invites can be sent at once by non admins' + `Maximum ${WorkspaceInvitesLimit} invites can be sent at once by non admins` ) } diff --git a/packages/server/modules/workspaces/tests/integration/invites.graph.spec.ts b/packages/server/modules/workspaces/tests/integration/invites.graph.spec.ts index e6d2cfa28..44f924d1b 100644 --- a/packages/server/modules/workspaces/tests/integration/invites.graph.spec.ts +++ b/packages/server/modules/workspaces/tests/integration/invites.graph.spec.ts @@ -248,17 +248,17 @@ describe('Workspaces Invites GQL', () => { expect(res.data?.workspaceMutations?.invites?.create).to.not.be.ok }) - it('batch inviting fails if more than 10 invites', async () => { + it('batch inviting fails if more than 200 invites', async () => { const res = await gqlHelpers.batchCreateInvites({ workspaceId: myFirstWorkspace.id, - input: times(11, () => ({ + input: times(201, () => ({ email: `asdasasd${Math.random()}@example.org`, role: WorkspaceRole.Member })) }) expect(res).to.haveGraphQLErrors( - 'Maximum 10 invites can be sent at once by non admins' + 'Maximum 200 invites can be sent at once by non admins' ) expect(res.data?.workspaceMutations?.invites?.batchCreate).to.not.be.ok })