🛂 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:
Baptiste Arnaud
2023-04-10 09:24:04 +02:00
parent e06f8186f6
commit 846dac0bf4
6 changed files with 15 additions and 34 deletions

View File

@@ -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,
}
})

View File

@@ -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
}