🛂 Add isQuarantined field in workspace
This commit is contained in:
@ -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
|
||||
}
|
||||
|
||||
|
@ -95,6 +95,7 @@ model Workspace {
|
||||
customChatsLimit Int?
|
||||
customStorageLimit Int?
|
||||
customSeatsLimit Int?
|
||||
isQuarantined Boolean @default(false)
|
||||
themeTemplates ThemeTemplate[]
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "Workspace" ADD COLUMN "isQuarantined" BOOLEAN NOT NULL DEFAULT false;
|
@ -89,6 +89,7 @@ model Workspace {
|
||||
customChatsLimit Int?
|
||||
customStorageLimit Int?
|
||||
customSeatsLimit Int?
|
||||
isQuarantined Boolean @default(false)
|
||||
themeTemplates ThemeTemplate[]
|
||||
}
|
||||
|
||||
|
@ -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>
|
||||
|
Reference in New Issue
Block a user