[object Object]

← back to George Gmail

send-with-attachment: resolve any account (steve-personal/agentabrams), not just office/info

23d49a6bb537108d152603dcdd125bdb4630252c · 2026-06-24 14:46:45 -0700 · Steve

Files touched

Diff

commit 23d49a6bb537108d152603dcdd125bdb4630252c
Author: Steve <steve@designerwallcoverings.com>
Date:   Wed Jun 24 14:46:45 2026 -0700

    send-with-attachment: resolve any account (steve-personal/agentabrams), not just office/info
---
 server.js | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/server.js b/server.js
index 9923e3b..1049f84 100644
--- a/server.js
+++ b/server.js
@@ -1253,11 +1253,11 @@ app.post('/api/send-with-attachment', async (req, res) => {
       return res.status(400).json({ error: 'attachments array required' });
     }
     { const _g = externalSendGuard(req); if (!_g.ok) { try { audit(account || '?', 'send-BLOCKED', { to, external: _g.external, reason: _g.reason }); } catch (e) {} return res.status(403).json({ error: _g.reason, blocked: true, external: _g.external }); } }
-    const useInfo = account === 'info';
-    const authClient = useInfo ? infoOauth2Client : oauth2Client;
-    const gmailClient = useInfo ? infoGmail : gmail;
+    // Resolve any account (steve-office / info / steve-personal / agentabrams),
+    // matching /api/send — not just office/info.
+    const { gmail: gmailClient, oauth: authClient, key: acctKey } = resolveAccount(req);
     if (!authClient || !gmailClient) {
-      return res.status(500).json({ error: `${useInfo ? 'info' : 'main'} account not configured` });
+      return res.status(500).json({ error: `account not configured: ${acctKey}` });
     }
 
     // Build MIME with nodemailer (handles UTF-8 subjects, multipart, base64 chunking correctly)
@@ -1292,7 +1292,7 @@ app.post('/api/send-with-attachment', async (req, res) => {
       messageId: result.data.id,
       threadId: result.data.threadId,
       from: fromAddr,
-      account: useInfo ? 'info' : 'main',
+      account: acctKey,
     });
   } catch (e) {
     res.status(500).json({ error: e.message });

← 2626a50 Add DELETE /api/drafts/:id route + make GET /api/drafts acco  ·  back to George Gmail  ·  auto-save: 2026-06-26T16:04:29 (1 files) — server.js 0ff8bf3 →