<?php
require __DIR__ . '/_bootstrap.php';

$licenseKey = input('license_key');
$machineId  = input('machine_id');

if ($licenseKey === '' || $machineId === '') {
    respond(['success' => false, 'message' => 'Missing license_key or machine_id'], 400);
}

$lic = findLicenseByKey($licenseKey);
if (!$lic) {
    respond(['success' => true]); // nothing to do
}

$stmt = db()->prepare('DELETE FROM activations WHERE license_id = ? AND machine_id = ?');
$stmt->execute([$lic['id'], $machineId]);

respond(['success' => true]);
