🛂 Add isQuarantined field in workspace
This commit is contained in:
@ -24,7 +24,6 @@ import {
|
|||||||
} from '../helpers'
|
} from '../helpers'
|
||||||
import { env, isDefined, omit } from '@typebot.io/lib'
|
import { env, isDefined, omit } from '@typebot.io/lib'
|
||||||
import { prefillVariables } from '@/features/variables/prefillVariables'
|
import { prefillVariables } from '@/features/variables/prefillVariables'
|
||||||
import { checkChatsUsage } from '@/features/usage/checkChatsUsage'
|
|
||||||
import { injectVariablesFromExistingResult } from '@/features/variables/injectVariablesFromExistingResult'
|
import { injectVariablesFromExistingResult } from '@/features/variables/injectVariablesFromExistingResult'
|
||||||
import { deepParseVariables } from '@/features/variables/deepParseVariable'
|
import { deepParseVariables } from '@/features/variables/deepParseVariable'
|
||||||
import { parseVariables } from '@/features/variables/parseVariables'
|
import { parseVariables } from '@/features/variables/parseVariables'
|
||||||
@ -246,9 +245,8 @@ const getTypebot = async (
|
|||||||
id: true,
|
id: true,
|
||||||
plan: true,
|
plan: true,
|
||||||
additionalChatsIndex: true,
|
additionalChatsIndex: true,
|
||||||
chatsLimitFirstEmailSentAt: true,
|
|
||||||
chatsLimitSecondEmailSentAt: true,
|
|
||||||
customChatsLimit: true,
|
customChatsLimit: true,
|
||||||
|
isQuarantined: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -274,19 +272,17 @@ const getTypebot = async (
|
|||||||
message: 'Typebot not found',
|
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({
|
throw new TRPCError({
|
||||||
code: 'BAD_REQUEST',
|
code: 'BAD_REQUEST',
|
||||||
message: 'Typebot is closed',
|
message: 'Typebot is closed',
|
||||||
})
|
})
|
||||||
|
|
||||||
typebotQuery && 'typebot' in typebotQuery
|
|
||||||
? await checkChatsUsage({
|
|
||||||
typebotId: parsedTypebot.id,
|
|
||||||
workspace: typebotQuery.typebot.workspace,
|
|
||||||
})
|
|
||||||
: false
|
|
||||||
|
|
||||||
return parsedTypebot
|
return parsedTypebot
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,6 +95,7 @@ model Workspace {
|
|||||||
customChatsLimit Int?
|
customChatsLimit Int?
|
||||||
customStorageLimit Int?
|
customStorageLimit Int?
|
||||||
customSeatsLimit Int?
|
customSeatsLimit Int?
|
||||||
|
isQuarantined Boolean @default(false)
|
||||||
themeTemplates ThemeTemplate[]
|
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?
|
customChatsLimit Int?
|
||||||
customStorageLimit Int?
|
customStorageLimit Int?
|
||||||
customSeatsLimit Int?
|
customSeatsLimit Int?
|
||||||
|
isQuarantined Boolean @default(false)
|
||||||
themeTemplates ThemeTemplate[]
|
themeTemplates ThemeTemplate[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,6 +48,7 @@ export const workspaceSchema = z.object({
|
|||||||
customChatsLimit: z.number().nullable(),
|
customChatsLimit: z.number().nullable(),
|
||||||
customStorageLimit: z.number().nullable(),
|
customStorageLimit: z.number().nullable(),
|
||||||
customSeatsLimit: z.number().nullable(),
|
customSeatsLimit: z.number().nullable(),
|
||||||
|
isQuarantined: z.boolean(),
|
||||||
}) satisfies z.ZodType<WorkspacePrisma>
|
}) satisfies z.ZodType<WorkspacePrisma>
|
||||||
|
|
||||||
export type Workspace = z.infer<typeof workspaceSchema>
|
export type Workspace = z.infer<typeof workspaceSchema>
|
||||||
|
Reference in New Issue
Block a user