mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
misc: added channels count validator
This commit is contained in:
@@ -14,6 +14,7 @@ import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
|
|||||||
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
|
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
|
||||||
import { AuthMode } from "@app/services/auth/auth-type";
|
import { AuthMode } from "@app/services/auth/auth-type";
|
||||||
import { ProjectFilterType } from "@app/services/project/project-types";
|
import { ProjectFilterType } from "@app/services/project/project-types";
|
||||||
|
import { validateSlackChannelsField } from "@app/services/slack/slack-auth-validators";
|
||||||
|
|
||||||
import { integrationAuthPubSchema, SanitizedProjectSchema } from "../sanitizedSchemas";
|
import { integrationAuthPubSchema, SanitizedProjectSchema } from "../sanitizedSchemas";
|
||||||
import { sanitizedServiceTokenSchema } from "../v2/service-token-router";
|
import { sanitizedServiceTokenSchema } from "../v2/service-token-router";
|
||||||
@@ -606,9 +607,9 @@ export const registerProjectRouter = async (server: FastifyZodProvider) => {
|
|||||||
body: z.object({
|
body: z.object({
|
||||||
slackIntegrationId: z.string(),
|
slackIntegrationId: z.string(),
|
||||||
isAccessRequestNotificationEnabled: z.boolean(),
|
isAccessRequestNotificationEnabled: z.boolean(),
|
||||||
accessRequestChannels: z.string(),
|
accessRequestChannels: validateSlackChannelsField,
|
||||||
isSecretRequestNotificationEnabled: z.boolean(),
|
isSecretRequestNotificationEnabled: z.boolean(),
|
||||||
secretRequestChannels: z.string()
|
secretRequestChannels: validateSlackChannelsField
|
||||||
}),
|
}),
|
||||||
response: {
|
response: {
|
||||||
200: ProjectSlackConfigsSchema.pick({
|
200: ProjectSlackConfigsSchema.pick({
|
||||||
|
|||||||
@@ -10,4 +10,7 @@ export const validateSlackChannelsField = z
|
|||||||
.split(",")
|
.split(",")
|
||||||
.map((id) => id.trim())
|
.map((id) => id.trim())
|
||||||
.join(", ");
|
.join(", ");
|
||||||
|
})
|
||||||
|
.refine((data) => data.split(",").length <= 20, {
|
||||||
|
message: "You can only select up to 20 slack channels"
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user