🛂 Prevent blocking everything once limit is reached
The idea is to make the hard limit less scary. I'd prefer manually reaching out to users when they are over their monthly limit
This commit is contained in:
@@ -58,7 +58,7 @@ export const getUploadUrl = publicProcedure
|
||||
'S3 not properly configured. Missing one of those variables: S3_ENDPOINT, S3_ACCESS_KEY, S3_SECRET_KEY',
|
||||
})
|
||||
|
||||
const hasReachedStorageLimit = await checkIfStorageLimitReached(typebotId)
|
||||
await checkIfStorageLimitReached(typebotId)
|
||||
const publicTypebot = (await prisma.publicTypebot.findFirst({
|
||||
where: { typebotId },
|
||||
select: {
|
||||
@@ -87,7 +87,7 @@ export const getUploadUrl = publicProcedure
|
||||
|
||||
return {
|
||||
presignedUrl,
|
||||
hasReachedStorageLimit,
|
||||
hasReachedStorageLimit: false,
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -284,19 +284,12 @@ const getTypebot = async (
|
||||
message: 'Typebot is closed',
|
||||
})
|
||||
|
||||
const hasReachedLimit =
|
||||
typebotQuery && 'typebot' in typebotQuery
|
||||
? await checkChatsUsage({
|
||||
typebotId: parsedTypebot.id,
|
||||
workspace: typebotQuery.typebot.workspace,
|
||||
})
|
||||
: false
|
||||
|
||||
if (hasReachedLimit)
|
||||
throw new TRPCError({
|
||||
code: 'FORBIDDEN',
|
||||
message: 'You have reached your chats limit',
|
||||
})
|
||||
typebotQuery && 'typebot' in typebotQuery
|
||||
? await checkChatsUsage({
|
||||
typebotId: parsedTypebot.id,
|
||||
workspace: typebotQuery.typebot.workspace,
|
||||
})
|
||||
: false
|
||||
|
||||
return parsedTypebot
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user