From 76a9eb699bf0e16c89c2c1b8388051f320530a13 Mon Sep 17 00:00:00 2001 From: Ani Date: Sun, 22 Sep 2024 19:05:41 +0100 Subject: [PATCH] Update: API v3, only return the requested OS Reduces response length by mot including unnecessary data --- update.php | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/update.php b/update.php index 05051eb..912e237 100644 --- a/update.php +++ b/update.php @@ -94,18 +94,29 @@ function check_for_updates( string $api, return $results; } + // For the v3 API, we only return the requested OSes $results['latest_build']['pr'] = $latest->pr; $results['latest_build']['datetime'] = $latest->merge; $results['latest_build']['version'] = $latest->version; - $results['latest_build']['windows']['download'] = $latest->get_url_windows(); - $results['latest_build']['windows']['size'] = $latest->size_win; - $results['latest_build']['windows']['checksum'] = $latest->checksum_win; - $results['latest_build']['linux']['download'] = $latest->get_url_linux(); - $results['latest_build']['linux']['size'] = $latest->size_linux; - $results['latest_build']['linux']['checksum'] = $latest->checksum_linux; - $results['latest_build']['mac']['download'] = $latest->get_url_mac(); - $results['latest_build']['mac']['size'] = $latest->size_mac; - $results['latest_build']['mac']['checksum'] = $latest->checksum_mac; + + if (substr($api, 1, 1) < 3 || (substr($api, 1, 1) >= 3 && $os_type === "windows")) + { + $results['latest_build']['windows']['download'] = $latest->get_url_windows(); + $results['latest_build']['windows']['size'] = $latest->size_win; + $results['latest_build']['windows']['checksum'] = $latest->checksum_win; + } + if (substr($api, 1, 1) < 3 || (substr($api, 1, 1) >= 3 && $os_type === "linux")) + { + $results['latest_build']['linux']['download'] = $latest->get_url_linux(); + $results['latest_build']['linux']['size'] = $latest->size_linux; + $results['latest_build']['linux']['checksum'] = $latest->checksum_linux; + } + if (substr($api, 1, 1) < 3 || (substr($api, 1, 1) >= 3 && $os_type === "macos")) + { + $results['latest_build']['mac']['download'] = $latest->get_url_mac(); + $results['latest_build']['mac']['size'] = $latest->size_mac; + $results['latest_build']['mac']['checksum'] = $latest->checksum_mac; + } if (!is_null($commit)) {