['oauth_token_env'=>'GMAIL_OAUTH_TOKEN', 'api'=>'https://gmail.googleapis.com/gmail/v1'], 'drive' => ['oauth_token_env'=>'GOOGLE_OAUTH_TOKEN', 'api'=>'https://www.googleapis.com/drive/v3'], 'slack' => ['token_env'=>'SLACK_BOT_TOKEN', 'api'=>'https://slack.com/api'], 'telegram' => ['token_env'=>'TELEGRAM_BOT_TOKEN', 'api'=>'https://api.telegram.org'], ]; if ($action === 'status') { $status = []; $secrets_lines = @file('/etc/weval/secrets.env'); foreach ($services as $name => $svc) { $env = $svc['oauth_token_env'] ?? $svc['token_env']; $has = false; foreach ($secrets_lines ?? [] as $line) { if (strpos($line, $env . '=') === 0) { $has = true; break; } } $status[$name] = $has ? 'configured' : 'missing_token'; } echo json_encode(['ok'=>true, 'services'=>$services, 'status'=>$status]); exit; } if ($action === 'gmail_draft') { $to = $_POST['to'] ?? ''; $subject = $_POST['subject'] ?? ''; $body = $_POST['body'] ?? ''; // Save to local drafts instead of sending (doctrine 69) $drafts = '/opt/wevads/vault/drafts'; @mkdir($drafts, 0755, true); $file = $drafts . '/gmail-draft-' . time() . '.md'; file_put_contents($file, "# Gmail Draft (unsent)\nTo: $to\nSubject: $subject\n\n$body\n"); echo json_encode(['ok'=>true, 'draft_saved'=>basename($file), 'note'=>'Zero auto-send doctrine 69. Send manually.']); exit; } if ($action === 'slack_post') { $channel = $_POST['channel'] ?? '#general'; $text = $_POST['text'] ?? ''; $drafts = '/opt/wevads/vault/drafts'; @mkdir($drafts, 0755, true); $file = $drafts . '/slack-draft-' . time() . '.md'; file_put_contents($file, "# Slack Draft (unsent)\nChannel: $channel\n\n$text\n"); echo json_encode(['ok'=>true, 'draft_saved'=>basename($file), 'note'=>'Zero auto-send doctrine 69. Send manually.']); exit; } echo json_encode(['ok'=>false, 'actions'=>['status','gmail_draft','slack_post'], 'doctrine'=>'69 zero auto-send']);