[object Object]

← back to Astek Landing

vendor-requests: resolve george send-token/auth across Mac + Kamatera paths (fix email_failed)

22e8ce8de20f5735073fe2b3aaae439d15bd08c0 · 2026-07-07 07:39:34 -0700 · Steve

Files touched

Diff

commit 22e8ce8de20f5735073fe2b3aaae439d15bd08c0
Author: Steve <steve@designerwallcoverings.com>
Date:   Tue Jul 7 07:39:34 2026 -0700

    vendor-requests: resolve george send-token/auth across Mac + Kamatera paths (fix email_failed)
---
 lib/vendor-requests.js | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/lib/vendor-requests.js b/lib/vendor-requests.js
index d3d70ae..cdf81fe 100644
--- a/lib/vendor-requests.js
+++ b/lib/vendor-requests.js
@@ -26,11 +26,26 @@ function envFrom(file, key) {
   try { const m = fs.readFileSync(file, 'utf8').match(new RegExp('^' + key + '=(.+)$', 'm')); return m ? m[1].replace(/^["']|["']$/g, '').trim() : ''; }
   catch { return ''; }
 }
-const SEND_TOKEN = envFrom(path.join(os.homedir(), 'Projects/george-gmail/.env'), 'GEORGE_EXTERNAL_SEND_TOKEN');
-const PGPASS = envFrom(path.join(os.homedir(), 'Projects/secrets-manager/.env'), 'DW_ADMIN_DB_PASSWORD');
+// Resolve a value from the first source that has it: an explicit process env var,
+// then each candidate .env file. Makes the lib portable across Mac (~/Projects/...)
+// and Kamatera, where george lives at ~/DW-Agents/gmail-agent — the old single
+// hard-coded path returned '' there, so the send token was empty and george
+// rejected every request (status email_failed).
+function firstEnv(key, files) {
+  if (process.env[key]) return process.env[key];
+  for (const f of files) { const v = envFrom(f, key); if (v) return v; }
+  return '';
+}
+const HOME = os.homedir();
+const GEORGE_ENVS = [
+  path.join(HOME, 'Projects/george-gmail/.env'),  // Mac dev
+  path.join(HOME, 'DW-Agents/gmail-agent/.env'),   // Kamatera prod
+];
+const SEND_TOKEN = firstEnv('GEORGE_EXTERNAL_SEND_TOKEN', GEORGE_ENVS);
+const PGPASS = firstEnv('DW_ADMIN_DB_PASSWORD', [path.join(HOME, 'Projects/secrets-manager/.env')]);
 // george basic auth — mirror george's own resolution: GEORGE_BASIC_AUTH from its
 // .env when set, else the historical fallback (admin + empty password).
-const GEORGE_AUTH = envFrom(path.join(os.homedir(), 'Projects/george-gmail/.env'), 'GEORGE_BASIC_AUTH') || 'admin:';
+const GEORGE_AUTH = firstEnv('GEORGE_BASIC_AUTH', GEORGE_ENVS) || 'admin:';
 
 let pool = null;
 function db() {

← 051d76d vendor-requests: self-bootstrap vendor_requests table (fix '  ·  back to Astek Landing  ·  auto-save: 2026-07-07T08:56:34 (1 files) — data/products.jso 6f71746 →