From fdf13c034769cf1966d21de570d29b44ff6ee3ab Mon Sep 17 00:00:00 2001 From: sdjdd Date: Thu, 18 Apr 2024 12:44:34 +0800 Subject: [PATCH] feat(next/api): category.meta.allow property --- next/api/src/router/ticket.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/next/api/src/router/ticket.ts b/next/api/src/router/ticket.ts index 9da8ead1c..c4d36fd6a 100644 --- a/next/api/src/router/ticket.ts +++ b/next/api/src/router/ticket.ts @@ -362,6 +362,15 @@ router.post('/', async (ctx) => { if (!category) { return ctx.throw(400, `Category ${data.categoryId} is not exists`); } + if (category.meta) { + const { allow } = category.meta; + if (typeof allow === 'string') { + const systemRoles = await roleService.getSystemRolesForUser(currentUser.id); + if (!systemRoles.includes(allow)) { + return ctx.throw(403, `You cannot create ticket with category ${category.id}`); + } + } + } const { title: fieldTitle, details, attachments, customFields } = extractSystemFields( data.customFields