carnet panel contact

This commit is contained in:
alma 2025-04-20 21:04:35 +02:00
parent c7bb1b0e07
commit 7ab64dce3c

View File

@ -59,20 +59,9 @@ export async function GET(request: Request) {
const files = await client.getDirectoryContents(path); const files = await client.getDirectoryContents(path);
console.log('Raw files response:', JSON.stringify(files, null, 2)); 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') { if (folder === 'Contacts') {
const vcfFiles = files return NextResponse.json(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);
} }
// For other folders, filter markdown 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); const { client, username } = await createWebDAVClient(session.user.id);
try { try {
// For Contacts folder, ensure we're using .vcf extension // Use the title as is, since it should already include the extension
const fileExtension = folder === 'Contacts' ? '.vcf' : '.md'; const path = `/files/${username}/Private/${folder}/${title}`;
const path = `/files/${username}/Private/${folder}/${title}${fileExtension}`;
console.log('Updating file at path:', path); console.log('Updating file at path:', path);
// Set the correct content type based on folder // Set the correct content type based on file extension
const contentType = folder === 'Contacts' ? 'text/vcard' : 'text/markdown'; const contentType = title.endsWith('.vcf') ? 'text/vcard' : 'text/markdown';
await client.putFileContents(path, content, { contentType }); await client.putFileContents(path, content, { contentType });
// Get the updated file details // Get the updated file details