From 846dac0bf40bdc27a4df12fe16779525aeece12a Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Mon, 10 Apr 2023 09:24:04 +0200 Subject: [PATCH] :passport_control: 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 --- .../inputs/fileUpload/api/getUploadUrl.ts | 4 ++-- .../src/features/chat/api/sendMessage.ts | 19 ++++++------------- .../emails/AlmostReachedChatsLimitEmail.tsx | 8 ++------ .../emails/AlmostReachedStorageLimitEmail.tsx | 8 +++----- .../src/emails/ReachedChatsLimitEmail.tsx | 7 ++----- .../src/emails/ReachedStorageLimitEmail.tsx | 3 --- 6 files changed, 15 insertions(+), 34 deletions(-) diff --git a/apps/viewer/src/features/blocks/inputs/fileUpload/api/getUploadUrl.ts b/apps/viewer/src/features/blocks/inputs/fileUpload/api/getUploadUrl.ts index 772d45682..0490f2ca7 100644 --- a/apps/viewer/src/features/blocks/inputs/fileUpload/api/getUploadUrl.ts +++ b/apps/viewer/src/features/blocks/inputs/fileUpload/api/getUploadUrl.ts @@ -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, } }) diff --git a/apps/viewer/src/features/chat/api/sendMessage.ts b/apps/viewer/src/features/chat/api/sendMessage.ts index 3de097009..5fad9dec1 100644 --- a/apps/viewer/src/features/chat/api/sendMessage.ts +++ b/apps/viewer/src/features/chat/api/sendMessage.ts @@ -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 } diff --git a/packages/emails/src/emails/AlmostReachedChatsLimitEmail.tsx b/packages/emails/src/emails/AlmostReachedChatsLimitEmail.tsx index 2187640da..385d5d52d 100644 --- a/packages/emails/src/emails/AlmostReachedChatsLimitEmail.tsx +++ b/packages/emails/src/emails/AlmostReachedChatsLimitEmail.tsx @@ -49,12 +49,8 @@ export const AlmostReachedChatsLimitEmail = ({ This limit will be reset on {readableResetDate}. - Your bots won't start the chat if you reach the limit before - this dateโ— - - - If you need more monthly responses, you will need to upgrade your - plan. + Upon this limit your bots will still continue to chat, but we ask + you kindly to upgrade your monthly chats limit. diff --git a/packages/emails/src/emails/AlmostReachedStorageLimitEmail.tsx b/packages/emails/src/emails/AlmostReachedStorageLimitEmail.tsx index 92a8cf021..e3394a16f 100644 --- a/packages/emails/src/emails/AlmostReachedStorageLimitEmail.tsx +++ b/packages/emails/src/emails/AlmostReachedStorageLimitEmail.tsx @@ -40,11 +40,9 @@ export const AlmostReachedStorageLimitEmail = ({ limit. - Your bots won't collect new files once you reach the limitโ— - - - To make sure it won't happen, you need to upgrade your plan - or delete existing results to free up space. + Upon this limit your bots will still continue to collect new + files, but we ask you kindly to upgrade your storage limit or + delete existing results to free up space. diff --git a/packages/emails/src/emails/ReachedChatsLimitEmail.tsx b/packages/emails/src/emails/ReachedChatsLimitEmail.tsx index fb6224771..914647c94 100644 --- a/packages/emails/src/emails/ReachedChatsLimitEmail.tsx +++ b/packages/emails/src/emails/ReachedChatsLimitEmail.tsx @@ -46,12 +46,9 @@ export const ReachedChatsLimitEmail = ({ It just happened, you've reached your monthly{' '} {readableChatsLimit} chats limit ๐Ÿ˜ฎ - - It means your bots are closed until {readableResetDate}โ— - - If you'd like to continue chatting with your users this - month, then you need to upgrade your plan. ๐Ÿš€ + If you'd like your bots to continue chatting with your users + this month, then you need to upgrade your plan. ๐Ÿš€ diff --git a/packages/emails/src/emails/ReachedStorageLimitEmail.tsx b/packages/emails/src/emails/ReachedStorageLimitEmail.tsx index 58dc09236..0872725d1 100644 --- a/packages/emails/src/emails/ReachedStorageLimitEmail.tsx +++ b/packages/emails/src/emails/ReachedStorageLimitEmail.tsx @@ -37,9 +37,6 @@ export const ReachedStorageLimitEmail = ({ It just happened, you've reached your {readableStorageLimit}{' '} storage limit ๐Ÿ˜ฎ - - It means your bots won't collect new files from your usersโ— - If you'd like to continue collecting files, then you need to upgrade your plan or remove existing results to free up space. ๐Ÿš€