2
0

🛂 (whatsapp) Disable whatsapp by default on duplication

This commit is contained in:
Baptiste Arnaud
2023-10-03 10:40:38 +02:00
parent 60c06aa9a9
commit 3292cccf51
3 changed files with 19 additions and 3 deletions

View File

@@ -80,7 +80,7 @@ export const createTypebot = authenticatedProcedure
: defaultGroups(), : defaultGroups(),
theme: typebot.theme ? typebot.theme : defaultTheme, theme: typebot.theme ? typebot.theme : defaultTheme,
settings: typebot.settings settings: typebot.settings
? sanitizeSettings(typebot.settings, workspace.plan) ? sanitizeSettings(typebot.settings, workspace.plan, 'create')
: defaultSettings({ : defaultSettings({
isBrandingEnabled: workspace.plan === Plan.FREE, isBrandingEnabled: workspace.plan === Plan.FREE,
}), }),

View File

@@ -142,7 +142,11 @@ export const updateTypebot = authenticatedProcedure
: undefined, : undefined,
theme: typebot.theme ? typebot.theme : undefined, theme: typebot.theme ? typebot.theme : undefined,
settings: typebot.settings settings: typebot.settings
? sanitizeSettings(typebot.settings, existingTypebot.workspace.plan) ? sanitizeSettings(
typebot.settings,
existingTypebot.workspace.plan,
'update'
)
: undefined, : undefined,
folderId: typebot.folderId, folderId: typebot.folderId,
variables: typebot.variables, variables: typebot.variables,

View File

@@ -9,7 +9,8 @@ import {
export const sanitizeSettings = ( export const sanitizeSettings = (
settings: Typebot['settings'], settings: Typebot['settings'],
workspacePlan: Plan workspacePlan: Plan,
mode: 'create' | 'update'
): Typebot['settings'] => ({ ): Typebot['settings'] => ({
...settings, ...settings,
general: { general: {
@@ -17,6 +18,17 @@ export const sanitizeSettings = (
isBrandingEnabled: isBrandingEnabled:
workspacePlan === Plan.FREE ? false : settings.general.isBrandingEnabled, workspacePlan === Plan.FREE ? false : settings.general.isBrandingEnabled,
}, },
whatsApp: settings.whatsApp
? {
...settings.whatsApp,
isEnabled:
mode === 'create'
? false
: workspacePlan === Plan.FREE
? false
: settings.whatsApp.isEnabled,
}
: undefined,
}) })
export const sanitizeGroups = export const sanitizeGroups =