carnet panel contact
This commit is contained in:
parent
3fcabdde25
commit
143b8156a1
@ -59,9 +59,20 @@ 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));
|
||||||
|
|
||||||
// Return all files for the Contacts folder
|
// For Contacts folder, only return VCF files
|
||||||
if (folder === 'Contacts') {
|
if (folder === 'Contacts') {
|
||||||
return NextResponse.json(files);
|
const vcfFiles = files
|
||||||
|
.filter((file: any) => file.basename.endsWith('.vcf') && !file.basename.endsWith('.vcf.md'))
|
||||||
|
.map((file: any) => ({
|
||||||
|
id: file.filename,
|
||||||
|
title: file.basename,
|
||||||
|
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
|
||||||
@ -145,12 +156,13 @@ export async function PUT(request: Request) {
|
|||||||
const { client, username } = await createWebDAVClient(session.user.id);
|
const { client, username } = await createWebDAVClient(session.user.id);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Use the title as is, since it should already include the extension
|
// For Contacts folder, ensure we're using .vcf extension
|
||||||
const path = `/files/${username}/Private/${folder}/${title}`;
|
const fileExtension = folder === 'Contacts' ? '.vcf' : '.md';
|
||||||
|
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 file extension
|
// Set the correct content type based on folder
|
||||||
const contentType = title.endsWith('.vcf') ? 'text/vcard' : 'text/markdown';
|
const contentType = folder === 'Contacts' ? '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
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user