From 1cef3358652d22be3e44b0e4209449fbf37d1ffc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A0nh=20Nh=C3=A2n?= Date: Sat, 14 Nov 2026 16:17:55 +0700 Subject: [PATCH] fix(data): authenticate emote catalog fetch --- tools/update-emote-catalog.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tools/update-emote-catalog.php b/tools/update-emote-catalog.php index 4dc0fdd..6599948 100644 --- a/tools/update-emote-catalog.php +++ b/tools/update-emote-catalog.php @@ -15,11 +15,18 @@ /** * @throws RuntimeException */ -function fetchJson(string $url) : string{ +function fetchJson(string $url, ?string $authorizationToken = null) : string{ + $headers = [ + "Accept: application/vnd.github+json", + "User-Agent: Axolotl-NPC-emote-catalog" + ]; + if($authorizationToken !== null){ + $headers[] = "Authorization: Bearer " . $authorizationToken; + } $context = stream_context_create([ "http" => [ "method" => "GET", - "header" => "Accept: application/vnd.github+json\r\nUser-Agent: Axolotl-NPC-emote-catalog\r\n", + "header" => implode("\r\n", $headers) . "\r\n", "timeout" => 30 ], "ssl" => [ @@ -35,7 +42,8 @@ function fetchJson(string $url) : string{ } try{ - $metadata = json_decode(fetchJson(SOURCE_API_URL), true, 512, JSON_THROW_ON_ERROR); + $authorizationToken = getenv("GH_TOKEN") ?: null; + $metadata = json_decode(fetchJson(SOURCE_API_URL, $authorizationToken), true, 512, JSON_THROW_ON_ERROR); if(!is_array($metadata) || !is_string($metadata["sha"] ?? null) || !is_string($metadata["download_url"] ?? null)){ throw new RuntimeException("The upstream metadata response is missing its source revision"); }