diff --git a/src/features/webhook/assembly/api/webhook.controller.ts b/src/features/webhook/assembly/api/webhook.controller.ts index 5619d55..09c0c19 100644 --- a/src/features/webhook/assembly/api/webhook.controller.ts +++ b/src/features/webhook/assembly/api/webhook.controller.ts @@ -19,6 +19,11 @@ export const handleWebhookEvent = async (req: NextRequest) => { const dropboxConnectionService = new DropboxConnectionsService(user) const connection = await dropboxConnectionService.getConnectionForWorkspace() + if (!connection.status) { + console.info(`Sync is not enabled for this workspace. Skipping webhook event`) + return NextResponse.json({}) + } + if (!connection.refreshToken) throw new APIError('No refresh token found', httpStatus.NOT_FOUND) if (!connection.accountId) throw new APIError('No accountId found', httpStatus.NOT_FOUND) diff --git a/src/utils/filePath.ts b/src/utils/filePath.ts index 211cc1b..95093f8 100644 --- a/src/utils/filePath.ts +++ b/src/utils/filePath.ts @@ -82,6 +82,15 @@ export function sanitizePath(path: string) { } export function sanitizeFileNameForAssembly(filename: string): string { + return unorm + .nfd(filename) // decompose accents + .replace(/[\u0300-\u036f]/g, '') // remove diacritics + .replace(/[^a-zA-Z0-9._/() -]/g, '_') // replace special chars with _ + .replace(/_+/g, '_') // collapse multiple _ + .replace(/^_+|_+$/g, '') // trim _ from ends +} + +export function getFaultyPath(filename: string): string { return unorm .nfd(filename) // decompose accents .replace(/[\u0300-\u036f]/g, '') // remove diacritics