2
0

🛂 Add isQuarantined field in workspace

This commit is contained in:
Baptiste Arnaud
2023-04-23 20:57:51 +02:00
parent bda34e3827
commit 69e1c4f20d
5 changed files with 12 additions and 11 deletions

View File

@ -24,7 +24,6 @@ import {
} from '../helpers'
import { env, isDefined, omit } from '@typebot.io/lib'
import { prefillVariables } from '@/features/variables/prefillVariables'
import { checkChatsUsage } from '@/features/usage/checkChatsUsage'
import { injectVariablesFromExistingResult } from '@/features/variables/injectVariablesFromExistingResult'
import { deepParseVariables } from '@/features/variables/deepParseVariable'
import { parseVariables } from '@/features/variables/parseVariables'
@ -246,9 +245,8 @@ const getTypebot = async (
id: true,
plan: true,
additionalChatsIndex: true,
chatsLimitFirstEmailSentAt: true,
chatsLimitSecondEmailSentAt: true,
customChatsLimit: true,
isQuarantined: true,
},
},
},
@ -274,19 +272,17 @@ const getTypebot = async (
message: 'Typebot not found',
})
if ('isClosed' in parsedTypebot && parsedTypebot.isClosed)
const isQuarantined =
typebotQuery &&
'typebot' in typebotQuery &&
typebotQuery.typebot.workspace.isQuarantined
if (('isClosed' in parsedTypebot && parsedTypebot.isClosed) || isQuarantined)
throw new TRPCError({
code: 'BAD_REQUEST',
message: 'Typebot is closed',
})
typebotQuery && 'typebot' in typebotQuery
? await checkChatsUsage({
typebotId: parsedTypebot.id,
workspace: typebotQuery.typebot.workspace,
})
: false
return parsedTypebot
}

View File

@ -95,6 +95,7 @@ model Workspace {
customChatsLimit Int?
customStorageLimit Int?
customSeatsLimit Int?
isQuarantined Boolean @default(false)
themeTemplates ThemeTemplate[]
}

View File

@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Workspace" ADD COLUMN "isQuarantined" BOOLEAN NOT NULL DEFAULT false;

View File

@ -89,6 +89,7 @@ model Workspace {
customChatsLimit Int?
customStorageLimit Int?
customSeatsLimit Int?
isQuarantined Boolean @default(false)
themeTemplates ThemeTemplate[]
}

View File

@ -48,6 +48,7 @@ export const workspaceSchema = z.object({
customChatsLimit: z.number().nullable(),
customStorageLimit: z.number().nullable(),
customSeatsLimit: z.number().nullable(),
isQuarantined: z.boolean(),
}) satisfies z.ZodType<WorkspacePrisma>
export type Workspace = z.infer<typeof workspaceSchema>