<?php
require_once __DIR__ . '/../includes/functions.php';
startSecureSession();

if (!isset($_SESSION['user_id'])) {
    echo json_encode(['status' => 'error', 'message' => 'Unauthorized']);
    exit;
}
$user = getUserById($_SESSION['user_id']);
if (!$user) {
    echo json_encode(['status' => 'error', 'message' => 'Invalid user']);
    exit;
}

// Since the Node daemon is gone, we don't need real-time ping.
// Just check if they have configured it.
if (empty($user['gmail_connected']) || empty($user['fampay_gmail'])) {
    echo json_encode(['status' => 'error', 'code' => 'NOT_CONFIGURED', 'message' => 'Not configured']);
    exit;
}

echo json_encode(['status' => 'success']);
