<?php
require_once '../../config/cors.php';
require_once '../../config/db.php';
require_once '../../helpers/response.php';
require_once '../../helpers/auth.php';

$admin = requireAdmin();
$data = json_decode(file_get_contents('php://input'), true);

$message_id = $data['message_id'] ?? null;

if (!$message_id) {
    sendError('Message ID required', 400);
}

$stmt = $pdo->prepare("UPDATE chat_messages SET is_deleted = TRUE WHERE id = ?");
$stmt->execute([$message_id]);

sendSuccess(null, 'Message deleted');
?>