🛂 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',
|
'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({
|
const publicTypebot = (await prisma.publicTypebot.findFirst({
|
||||||
where: { typebotId },
|
where: { typebotId },
|
||||||
select: {
|
select: {
|
||||||
@ -87,7 +87,7 @@ export const getUploadUrl = publicProcedure
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
presignedUrl,
|
presignedUrl,
|
||||||
hasReachedStorageLimit,
|
hasReachedStorageLimit: false,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -284,19 +284,12 @@ const getTypebot = async (
|
|||||||
message: 'Typebot is closed',
|
message: 'Typebot is closed',
|
||||||
})
|
})
|
||||||
|
|
||||||
const hasReachedLimit =
|
typebotQuery && 'typebot' in typebotQuery
|
||||||
typebotQuery && 'typebot' in typebotQuery
|
? await checkChatsUsage({
|
||||||
? await checkChatsUsage({
|
typebotId: parsedTypebot.id,
|
||||||
typebotId: parsedTypebot.id,
|
workspace: typebotQuery.typebot.workspace,
|
||||||
workspace: typebotQuery.typebot.workspace,
|
})
|
||||||
})
|
: false
|
||||||
: false
|
|
||||||
|
|
||||||
if (hasReachedLimit)
|
|
||||||
throw new TRPCError({
|
|
||||||
code: 'FORBIDDEN',
|
|
||||||
message: 'You have reached your chats limit',
|
|
||||||
})
|
|
||||||
|
|
||||||
return parsedTypebot
|
return parsedTypebot
|
||||||
}
|
}
|
||||||
|
@ -49,12 +49,8 @@ export const AlmostReachedChatsLimitEmail = ({
|
|||||||
</Text>
|
</Text>
|
||||||
<Text>This limit will be reset on {readableResetDate}.</Text>
|
<Text>This limit will be reset on {readableResetDate}.</Text>
|
||||||
<Text fontWeight="800">
|
<Text fontWeight="800">
|
||||||
Your bots won't start the chat if you reach the limit before
|
Upon this limit your bots will still continue to chat, but we ask
|
||||||
this date❗
|
you kindly to upgrade your monthly chats limit.
|
||||||
</Text>
|
|
||||||
<Text>
|
|
||||||
If you need more monthly responses, you will need to upgrade your
|
|
||||||
plan.
|
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
<MjmlSpacer height="24px" />
|
<MjmlSpacer height="24px" />
|
||||||
|
@ -40,11 +40,9 @@ export const AlmostReachedStorageLimitEmail = ({
|
|||||||
limit.
|
limit.
|
||||||
</Text>
|
</Text>
|
||||||
<Text fontWeight="800">
|
<Text fontWeight="800">
|
||||||
Your bots won't collect new files once you reach the limit❗
|
Upon this limit your bots will still continue to collect new
|
||||||
</Text>
|
files, but we ask you kindly to upgrade your storage limit or
|
||||||
<Text>
|
delete existing results to free up space.
|
||||||
To make sure it won't happen, you need to upgrade your plan
|
|
||||||
or delete existing results to free up space.
|
|
||||||
</Text>
|
</Text>
|
||||||
<MjmlSpacer height="24px" />
|
<MjmlSpacer height="24px" />
|
||||||
<Button link={url}>Upgrade workspace</Button>
|
<Button link={url}>Upgrade workspace</Button>
|
||||||
|
@ -46,12 +46,9 @@ export const ReachedChatsLimitEmail = ({
|
|||||||
It just happened, you've reached your monthly{' '}
|
It just happened, you've reached your monthly{' '}
|
||||||
{readableChatsLimit} chats limit 😮
|
{readableChatsLimit} chats limit 😮
|
||||||
</Text>
|
</Text>
|
||||||
<Text fontWeight="800">
|
|
||||||
It means your bots are closed until {readableResetDate}❗
|
|
||||||
</Text>
|
|
||||||
<Text>
|
<Text>
|
||||||
If you'd like to continue chatting with your users this
|
If you'd like your bots to continue chatting with your users
|
||||||
month, then you need to upgrade your plan. 🚀
|
this month, then you need to upgrade your plan. 🚀
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
<MjmlSpacer height="24px" />
|
<MjmlSpacer height="24px" />
|
||||||
|
@ -37,9 +37,6 @@ export const ReachedStorageLimitEmail = ({
|
|||||||
It just happened, you've reached your {readableStorageLimit}{' '}
|
It just happened, you've reached your {readableStorageLimit}{' '}
|
||||||
storage limit 😮
|
storage limit 😮
|
||||||
</Text>
|
</Text>
|
||||||
<Text fontWeight="800">
|
|
||||||
It means your bots won't collect new files from your users❗
|
|
||||||
</Text>
|
|
||||||
<Text>
|
<Text>
|
||||||
If you'd like to continue collecting files, then you need to
|
If you'd like to continue collecting files, then you need to
|
||||||
upgrade your plan or remove existing results to free up space. 🚀
|
upgrade your plan or remove existing results to free up space. 🚀
|
||||||
|
Reference in New Issue
Block a user