diff --git a/app/api/nextcloud/files/route.ts b/app/api/nextcloud/files/route.ts index d8f76f01..edc26a55 100644 --- a/app/api/nextcloud/files/route.ts +++ b/app/api/nextcloud/files/route.ts @@ -59,20 +59,9 @@ export async function GET(request: Request) { const files = await client.getDirectoryContents(path); console.log('Raw files response:', JSON.stringify(files, null, 2)); - // For Contacts folder, return only VCF files + // Return all files for the Contacts folder if (folder === 'Contacts') { - const vcfFiles = files - .filter((file: any) => file.basename.endsWith('.vcf') && !file.basename.endsWith('.vcf.md')) - .map((file: any) => ({ - id: file.filename, - title: file.basename.replace('.vcf', ''), - lastModified: new Date(file.lastmod).toISOString(), - size: file.size, - type: 'file', - mime: file.mime, - etag: file.etag - })); - return NextResponse.json(vcfFiles); + return NextResponse.json(files); } // For other folders, filter markdown files @@ -156,13 +145,12 @@ export async function PUT(request: Request) { const { client, username } = await createWebDAVClient(session.user.id); try { - // For Contacts folder, ensure we're using .vcf extension - const fileExtension = folder === 'Contacts' ? '.vcf' : '.md'; - const path = `/files/${username}/Private/${folder}/${title}${fileExtension}`; + // Use the title as is, since it should already include the extension + const path = `/files/${username}/Private/${folder}/${title}`; console.log('Updating file at path:', path); - // Set the correct content type based on folder - const contentType = folder === 'Contacts' ? 'text/vcard' : 'text/markdown'; + // Set the correct content type based on file extension + const contentType = title.endsWith('.vcf') ? 'text/vcard' : 'text/markdown'; await client.putFileContents(path, content, { contentType }); // Get the updated file details