31 lines
1.1 KiB
PHP
31 lines
1.1 KiB
PHP
<?php
|
|
require_once __DIR__ . '/../config/config_enhanced.php';
|
|
require_once __DIR__ . '/../config/config.php';
|
|
header('Content-Type: application/json; charset=utf-8');
|
|
|
|
if (function_exists('requireAuthentication')) requireAuthentication();
|
|
|
|
$input = json_decode(file_get_contents('php://input'), true) ?: $_POST;
|
|
$conversationId = isset($input['conversation_id']) ? intval($input['conversation_id']) : null;
|
|
$userId = isset($input['user_id']) ? intval($input['user_id']) : null;
|
|
|
|
if (!$conversationId && !$userId) {
|
|
http_response_code(400);
|
|
echo json_encode(['success' => false, 'error' => 'conversation_id or user_id required']);
|
|
exit;
|
|
}
|
|
|
|
try {
|
|
$db = Database::getInstance();
|
|
if ($conversationId) {
|
|
$db->execute('DELETE FROM conversations WHERE id = ?', [$conversationId]);
|
|
}
|
|
if ($userId) {
|
|
$db->execute('DELETE FROM conversations WHERE user_id = ?', [$userId]);
|
|
}
|
|
echo json_encode(['success' => true]);
|
|
} catch (Exception $e) {
|
|
http_response_code(500);
|
|
echo json_encode(['success' => false, 'error' => $e->getMessage()]);
|
|
}
|