Agenda refactor
This commit is contained in:
parent
ed580b8cc2
commit
e60d98b03a
@ -27,8 +27,8 @@ export async function getInfomaniakCalDAVClient(
|
|||||||
password: string
|
password: string
|
||||||
): Promise<WebDAVClient> {
|
): Promise<WebDAVClient> {
|
||||||
// Infomaniak CalDAV base URL (from Infomaniak sync assistant)
|
// Infomaniak CalDAV base URL (from Infomaniak sync assistant)
|
||||||
// Base URL is https://sync.infomaniak.com, CalDAV endpoint is accessed via /caldav path
|
// The actual CalDAV endpoint is at /caldav path
|
||||||
const baseUrl = 'https://sync.infomaniak.com';
|
const baseUrl = 'https://sync.infomaniak.com/caldav';
|
||||||
|
|
||||||
const client = createClient(baseUrl, {
|
const client = createClient(baseUrl, {
|
||||||
username: email,
|
username: email,
|
||||||
@ -48,40 +48,8 @@ export async function discoverInfomaniakCalendars(
|
|||||||
try {
|
try {
|
||||||
const client = await getInfomaniakCalDAVClient(email, password);
|
const client = await getInfomaniakCalDAVClient(email, password);
|
||||||
|
|
||||||
// List all calendars using PROPFIND
|
// List all calendars using PROPFIND on root
|
||||||
// Try different paths: root, /caldav, /calendars/{username}
|
const items = await client.getDirectoryContents('/');
|
||||||
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)}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const calendars: CalDAVCalendar[] = [];
|
const calendars: CalDAVCalendar[] = [];
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user