Files
whatsapp/api/release_hold.php
T
2026-01-21 02:45:59 -05:00

30 lines
957 B
PHP

<?php
require_once '../config/config.php';
header('Content-Type: application/json; charset=utf-8');
requireAuthentication();
try {
$input = json_decode(file_get_contents('php://input'), true) ?: $_POST;
$userId = isset($input['user_id']) ? intval($input['user_id']) : 0;
if (!$userId) {
http_response_code(400);
echo json_encode(['success' => false, 'error' => 'user_id required']);
exit;
}
$db = Database::getInstance();
$user = $db->fetch('SELECT phone_number FROM users WHERE id = :id', ['id' => $userId]);
if (!$user) {
http_response_code(404);
echo json_encode(['success' => false, 'error' => 'User not found']);
exit;
}
$db->update('users', ['on_hold' => 0], 'id = :id', ['id' => $userId]);
echo json_encode(['success' => true]);
} catch (Exception $e) {
http_response_code(500);
echo json_encode(['success' => false, 'error' => $e->getMessage()]);
}