This commit is contained in:
lizandrogd
2026-01-21 15:12:15 -05:00
parent 75b8f469f4
commit ddc9a68a40
4 changed files with 51 additions and 6 deletions
+11 -3
View File
@@ -20,9 +20,17 @@ try {
exit;
}
$db->update('users', ['on_hold' => 0], 'id = :id', ['id' => $userId]);
echo json_encode(['success' => true]);
// Use BotService to release hold (sends notification and clears flags)
try {
require_once __DIR__ . '/../services/BotService.php';
$bot = new BotService();
$bot->releaseHold($user['phone_number']);
echo json_encode(['success' => true]);
} catch (Exception $e) {
// Fallback to direct DB update if BotService fails
$db->update('users', ['on_hold' => 0, 'advisor_requested' => 0, 'bot_paused_until' => null], 'id = :id', ['id' => $userId]);
echo json_encode(['success' => true, 'warning' => 'BotService failed, flags cleared directly']);
}
} catch (Exception $e) {
http_response_code(500);
echo json_encode(['success' => false, 'error' => $e->getMessage()]);