From a886b4b30ee021ae6396121b95a706a9c0b02874 Mon Sep 17 00:00:00 2001 From: jtricerolph Date: Thu, 2 Jul 2026 00:33:48 +0000 Subject: [PATCH] Add connection tests for Workforce and SMTP integrations Co-Authored-By: Claude Sonnet 4.6 --- src/routes/integrations.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/routes/integrations.js b/src/routes/integrations.js index 008d10b..c664791 100644 --- a/src/routes/integrations.js +++ b/src/routes/integrations.js @@ -87,6 +87,26 @@ export async function integrationRoutes(app) { try { if (req.params.slug === 'newbook') await newbookTest(creds) else if (req.params.slug === 'resos') await resosTest(creds) + else if (req.params.slug === 'workforce') { + const baseUrl = creds.base_url || 'https://my.workforce.com' + const res = await fetch(`${baseUrl}/api/oauth/token`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ grant_type: 'password', username: creds.email, password: creds.password, scope: 'default' }), + signal: AbortSignal.timeout(8000), + }) + if (!res.ok) throw new Error(`Workforce auth failed (${res.status})`) + const data = await res.json() + if (!data.access_token) throw new Error('No access token returned') + } + else if (req.params.slug === 'smtp') { + const nodemailer = await import('nodemailer') + const transporter = nodemailer.default.createTransport({ + host: creds.host, port: parseInt(creds.port || '587'), + auth: { user: creds.user, pass: creds.pass }, + }) + await transporter.verify() + } else return reply.status(400).send({ error: `No test available for ${req.params.slug}` }) return { ok: true } } catch (e) {