mirror of
https://github.com/myronblair/jarvis
synced 2026-07-28 08:43:00 -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:
@@ -324,16 +324,35 @@ if ($action) {
|
||||
|
||||
// ── USERS ────────────────────────────────────────────────────────────
|
||||
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
|
||||
// (165.22.1.228/api/email with a spoofed Host header) — a leftover from
|
||||
// before JARVIS moved to this VM (211). That endpoint no longer exists
|
||||
// (404), so the inbox always failed. Reads the local email_triage table
|
||||
// directly now, same source gmail_triage jobs already write to, matching
|
||||
// the pattern email_action_items already used.
|
||||
$acct = $_GET['account'] ?? 'all';
|
||||
$force = !empty($_GET['force']) ? '&force=1' : '';
|
||||
$ch = curl_init('https://165.22.1.228/api/email?account=' . $acct . $force);
|
||||
curl_setopt_array($ch,[CURLOPT_RETURNTRANSFER=>true,CURLOPT_TIMEOUT=>25,
|
||||
CURLOPT_SSL_VERIFYPEER=>false,CURLOPT_SSL_VERIFYHOST=>false,
|
||||
CURLOPT_HTTPHEADER=>['Host: jarvis.orbishosting.com']]);
|
||||
$r = curl_exec($ch); $code = curl_getinfo($ch,CURLINFO_HTTP_CODE); curl_close($ch);
|
||||
if($code===200 && $r) j(json_decode($r,true));
|
||||
else j(['error'=>'Email fetch failed (HTTP '.$code.')']);
|
||||
$where = '1=1'; $params = [];
|
||||
if ($acct && $acct !== 'all') { $where .= ' AND account=?'; $params[] = $acct; }
|
||||
$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':
|
||||
$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