<?php
require_once __DIR__ . '/../config/config.php';
$db = Database::getInstance();
$rows = $db->fetchAll("SELECT id,user_id,message_id,message_type,content,media_url,filename,created_at,local_file,local_thumb FROM conversations WHERE message_type IN ('image','video','audio') AND (local_file IS NULL OR local_file = '') ORDER BY created_at DESC LIMIT 50");
if (!$rows) { echo "No pending media to store\n"; exit; }
echo json_encode($rows, JSON_PRETTY_PRINT) . "\n";