Agenda refactor
This commit is contained in:
parent
ed580b8cc2
commit
e60d98b03a
@ -27,8 +27,8 @@ export async function getInfomaniakCalDAVClient(
|
||||
password: string
|
||||
): Promise<WebDAVClient> {
|
||||
// Infomaniak CalDAV base URL (from Infomaniak sync assistant)
|
||||
// Base URL is https://sync.infomaniak.com, CalDAV endpoint is accessed via /caldav path
|
||||
const baseUrl = 'https://sync.infomaniak.com';
|
||||
// The actual CalDAV endpoint is at /caldav path
|
||||
const baseUrl = 'https://sync.infomaniak.com/caldav';
|
||||
|
||||
const client = createClient(baseUrl, {
|
||||
username: email,
|
||||
@ -48,40 +48,8 @@ export async function discoverInfomaniakCalendars(
|
||||
try {
|
||||
const client = await getInfomaniakCalDAVClient(email, password);
|
||||
|
||||
// List all calendars using PROPFIND
|
||||
// Try different paths: root, /caldav, /calendars/{username}
|
||||
let items;
|
||||
let triedPaths: string[] = [];
|
||||
|
||||
// Try root path first
|
||||
try {
|
||||
logger.debug('Trying CalDAV discovery on root path /');
|
||||
items = await client.getDirectoryContents('/');
|
||||
logger.debug(`CalDAV discovery succeeded on root path, found ${items.length} items`);
|
||||
} catch (rootError) {
|
||||
triedPaths.push('/');
|
||||
logger.debug('Root path failed, trying /caldav path');
|
||||
|
||||
// Try /caldav path
|
||||
try {
|
||||
items = await client.getDirectoryContents('/caldav');
|
||||
logger.debug(`CalDAV discovery succeeded on /caldav path, found ${items.length} items`);
|
||||
} catch (caldavError) {
|
||||
triedPaths.push('/caldav');
|
||||
|
||||
// Try /calendars/{username} path
|
||||
const username = email.split('@')[0];
|
||||
const calendarsPath = `/calendars/${username}`;
|
||||
logger.debug(`Trying CalDAV discovery on ${calendarsPath} path`);
|
||||
try {
|
||||
items = await client.getDirectoryContents(calendarsPath);
|
||||
logger.debug(`CalDAV discovery succeeded on ${calendarsPath} path, found ${items.length} items`);
|
||||
} catch (calendarsError) {
|
||||
triedPaths.push(calendarsPath);
|
||||
throw new Error(`CalDAV discovery failed on all paths (${triedPaths.join(', ')}). Last error: ${calendarsError instanceof Error ? calendarsError.message : String(calendarsError)}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
// List all calendars using PROPFIND on root
|
||||
const items = await client.getDirectoryContents('/');
|
||||
|
||||
const calendars: CalDAVCalendar[] = [];
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user