mirror of
https://github.com/myronblair/jarvis
synced 2026-07-28 00:34:35 -05:00
Fix Email Intelligence inbox 404: was proxying to the old DO-hosted JARVIS (165.22.1.228/api/email), a dead endpoint since the move to VM211. Now reads email_triage directly, matching the pattern email_action_items already used.
This commit is contained in:
+29
-10
@@ -324,16 +324,35 @@ if ($action) {
|
|||||||
|
|
||||||
// ── USERS ────────────────────────────────────────────────────────────
|
// ── USERS ────────────────────────────────────────────────────────────
|
||||||
case 'email_inbox':
|
case 'email_inbox':
|
||||||
// Call via server's own IP — REMOTE_ADDR matches JARVIS_IP so auth bypass applies
|
// Fixed 2026-07-07: this used to proxy to the OLD DO-hosted JARVIS
|
||||||
$acct = $_GET['account'] ?? 'all';
|
// (165.22.1.228/api/email with a spoofed Host header) — a leftover from
|
||||||
$force = !empty($_GET['force']) ? '&force=1' : '';
|
// before JARVIS moved to this VM (211). That endpoint no longer exists
|
||||||
$ch = curl_init('https://165.22.1.228/api/email?account=' . $acct . $force);
|
// (404), so the inbox always failed. Reads the local email_triage table
|
||||||
curl_setopt_array($ch,[CURLOPT_RETURNTRANSFER=>true,CURLOPT_TIMEOUT=>25,
|
// directly now, same source gmail_triage jobs already write to, matching
|
||||||
CURLOPT_SSL_VERIFYPEER=>false,CURLOPT_SSL_VERIFYHOST=>false,
|
// the pattern email_action_items already used.
|
||||||
CURLOPT_HTTPHEADER=>['Host: jarvis.orbishosting.com']]);
|
$acct = $_GET['account'] ?? 'all';
|
||||||
$r = curl_exec($ch); $code = curl_getinfo($ch,CURLINFO_HTTP_CODE); curl_close($ch);
|
$where = '1=1'; $params = [];
|
||||||
if($code===200 && $r) j(json_decode($r,true));
|
if ($acct && $acct !== 'all') { $where .= ' AND account=?'; $params[] = $acct; }
|
||||||
else j(['error'=>'Email fetch failed (HTTP '.$code.')']);
|
$rows = JarvisDB::query(
|
||||||
|
"SELECT account, from_name, from_email, subject, date_received, summary, category
|
||||||
|
FROM email_triage WHERE {$where} ORDER BY date_received DESC LIMIT 100",
|
||||||
|
$params
|
||||||
|
) ?? [];
|
||||||
|
$recent = array_map(function($r) {
|
||||||
|
return [
|
||||||
|
'account' => $r['account'],
|
||||||
|
'from_name' => $r['from_name'],
|
||||||
|
'from_email'=> $r['from_email'],
|
||||||
|
'subject' => $r['subject'],
|
||||||
|
'date' => $r['date_received'],
|
||||||
|
'preview' => $r['summary'],
|
||||||
|
'unread' => false,
|
||||||
|
];
|
||||||
|
}, $rows);
|
||||||
|
$actionCount = JarvisDB::single(
|
||||||
|
"SELECT COUNT(*) AS c FROM email_actions WHERE dismissed=0 AND task_id IS NULL AND appointment_id IS NULL"
|
||||||
|
);
|
||||||
|
j(['summary' => ['recent' => $recent], 'action_items_count' => (int)($actionCount['c'] ?? 0)]);
|
||||||
|
|
||||||
case 'email_action_items':
|
case 'email_action_items':
|
||||||
$rows = JarvisDB::query("SELECT * FROM email_actions WHERE dismissed=0 AND task_id IS NULL AND appointment_id IS NULL ORDER BY received_at DESC LIMIT 100") ?? [];
|
$rows = JarvisDB::query("SELECT * FROM email_actions WHERE dismissed=0 AND task_id IS NULL AND appointment_id IS NULL ORDER BY received_at DESC LIMIT 100") ?? [];
|
||||||
|
|||||||
Reference in New Issue
Block a user