<?php
require_once __DIR__ . '/../config/config.php';
$db = Database::getInstance();
$phone = $argv[1] ?? '573022548060';
$rows = $db->fetchAll("SELECT c.id, c.message_id, c.direction, c.message_type, c.content, c.created_at, u.phone_number FROM conversations c JOIN users u ON c.user_id=u.id WHERE u.phone_number = ? ORDER BY c.created_at DESC LIMIT 5", [$phone]);
header('Content-Type: application/json');
echo json_encode($rows, JSON_PRETTY_PRINT);
