@ -10,6 +10,7 @@ import { z } from 'zod'
|
|||||||
import {
|
import {
|
||||||
isCustomDomainNotAvailable,
|
isCustomDomainNotAvailable,
|
||||||
isPublicIdNotAvailable,
|
isPublicIdNotAvailable,
|
||||||
|
sanitizeCustomDomain,
|
||||||
sanitizeGroups,
|
sanitizeGroups,
|
||||||
sanitizeSettings,
|
sanitizeSettings,
|
||||||
} from '../helpers/sanitizers'
|
} from '../helpers/sanitizers'
|
||||||
@ -201,8 +202,10 @@ export const updateTypebot = authenticatedProcedure
|
|||||||
: typebot.publicId && isPublicIdValid(typebot.publicId)
|
: typebot.publicId && isPublicIdValid(typebot.publicId)
|
||||||
? typebot.publicId
|
? typebot.publicId
|
||||||
: undefined,
|
: undefined,
|
||||||
customDomain:
|
customDomain: await sanitizeCustomDomain({
|
||||||
typebot.customDomain === null ? null : typebot.customDomain,
|
customDomain: typebot.customDomain,
|
||||||
|
workspaceId: existingTypebot.workspace.id,
|
||||||
|
}),
|
||||||
isClosed: typebot.isClosed,
|
isClosed: typebot.isClosed,
|
||||||
whatsAppCredentialsId: typebot.whatsAppCredentialsId ?? undefined,
|
whatsAppCredentialsId: typebot.whatsAppCredentialsId ?? undefined,
|
||||||
updatedAt: typebot.updatedAt,
|
updatedAt: typebot.updatedAt,
|
||||||
|
@ -163,3 +163,20 @@ export const sanitizeFolderId = async ({
|
|||||||
})
|
})
|
||||||
return folderCount !== 0 ? folderId : undefined
|
return folderCount !== 0 ? folderId : undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const sanitizeCustomDomain = async ({
|
||||||
|
customDomain,
|
||||||
|
workspaceId,
|
||||||
|
}: {
|
||||||
|
customDomain?: string | null
|
||||||
|
workspaceId: string
|
||||||
|
}) => {
|
||||||
|
if (!customDomain) return customDomain
|
||||||
|
const domainCount = await prisma.customDomain.count({
|
||||||
|
where: {
|
||||||
|
name: customDomain?.split('/')[0],
|
||||||
|
workspaceId,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
return domainCount === 0 ? null : customDomain
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user