diff --git a/src/routes/integrations.js b/src/routes/integrations.js index 51533ca..de42318 100644 --- a/src/routes/integrations.js +++ b/src/routes/integrations.js @@ -118,6 +118,27 @@ export async function integrationRoutes(app) { }) await transporter.verify() } + else if (req.params.slug === 'nextcloud') { + if (!creds.base_url || !creds.username || !creds.password) throw new Error('Nextcloud base URL, username and password are required') + const url = `${creds.base_url.replace(/\/$/, '')}/remote.php/dav/files/${encodeURIComponent(creds.username)}/` + const res = await fetch(url, { + method: 'PROPFIND', + headers: { Authorization: `Basic ${Buffer.from(`${creds.username}:${creds.password}`).toString('base64')}`, Depth: '0' }, + signal: AbortSignal.timeout(8000), + }) + if (res.status === 401) throw new Error('Invalid Nextcloud credentials') + if (!res.ok) throw new Error(`Nextcloud returned ${res.status}`) + } + else if (req.params.slug === 'azure') { + if (!creds.endpoint || !creds.api_key) throw new Error('Azure endpoint and API key are required') + const base = creds.endpoint.replace(/\/$/, '') + const res = await fetch(`${base}/documentintelligence/info?api-version=2024-11-30`, { + headers: { 'Ocp-Apim-Subscription-Key': creds.api_key }, + signal: AbortSignal.timeout(8000), + }) + if (res.status === 401 || res.status === 403) throw new Error('Invalid Azure API key') + if (!res.ok) throw new Error(`Azure returned ${res.status}`) + } else return reply.status(400).send({ error: `No test available for ${req.params.slug}` }) return { ok: true } } catch (e) {