json-api/fetchupd.php

39 lines
1.1 KiB
PHP
Raw Permalink Normal View History

2019-09-14 17:38:35 +02:00
<?php
require_once 'api/fetchupd.php';
require_once 'shared/main.php';
require_once 'shared/ratelimits.php';
$arch = isset($_GET['arch']) ? $_GET['arch'] : 'amd64';
$ring = isset($_GET['ring']) ? $_GET['ring'] : 'WIF';
$flight = isset($_GET['flight']) ? $_GET['flight'] : 'Active';
$build = isset($_GET['build']) ? $_GET['build'] : 'latest';
$sku = isset($_GET['sku']) ? $_GET['sku'] : '48';
2021-02-06 14:30:55 +01:00
$type = isset($_GET['type']) ? $_GET['type'] : 'Production';
2019-09-14 17:38:35 +02:00
header('Content-Type: application/json');
2021-02-06 14:30:55 +01:00
$resource = hash('sha1', strtolower("fetch-$arch-$ring-$flight-$build-$sku-$type"));
2019-09-14 17:38:35 +02:00
if(checkIfUserIsRateLimited($resource)) {
http_response_code(429);
sendResponse(['error' => 'USER_RATE_LIMITED']);
die();
}
2021-02-06 14:30:55 +01:00
$apiResponse = uupFetchUpd($arch, $ring, $flight, $build, 0, $sku, $type, 1);
2019-09-14 17:38:35 +02:00
if(isset($apiResponse['error'])) {
switch($apiResponse['error']) {
case 'EMPTY_FILELIST':
http_response_code(500);
break;
case 'NO_UPDATE_FOUND':
http_response_code(500);
break;
default:
http_response_code(400);
}
}
sendResponse($apiResponse);