Feat: Increase invite limit from 10 to 200 (#4618)
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
export const ProjectInviteResourceType = 'project'
|
||||
export const ServerInviteResourceType = 'server'
|
||||
export const ServerInviteLimit = 200
|
||||
|
||||
@@ -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`
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export const WorkspaceInvitesLimit = 200
|
||||
@@ -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`
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user