From b7aa1c17689a4e5e11c81cf870dd995c6ec18efe Mon Sep 17 00:00:00 2001 From: Crypta Eve Date: Mon, 27 Jan 2025 00:30:48 +1030 Subject: [PATCH] fix: update ua in invoke, not constructor (#423) --- src/Services/EseyeClient.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Services/EseyeClient.php b/src/Services/EseyeClient.php index a90c7a4c..53d649fc 100644 --- a/src/Services/EseyeClient.php +++ b/src/Services/EseyeClient.php @@ -57,7 +57,8 @@ public function __construct() $config->http_client = Client::class; $config->http_stream_factory = HttpFactory::class; $config->http_request_factory = HttpFactory::class; - $config->http_user_agent = sprintf('SeAT %s/%s', $version, setting('admin_contact', true)); + $config->http_user_agent = sprintf('SeAT %s', $version); + $config->http_user_agent_eveapi_version = $version; //store this for later. $config->logger = Log::channel('eseye'); $config->cache = Cache::store('eseye'); @@ -190,6 +191,16 @@ public function setBody(array $body): EsiClient */ public function invoke(string $method, string $uri, array $uri_data = []): EsiResponse { + // Here we update the user--agent with contact information. + // At this point it is updating it each call, at the cost + // of a cache request each time. If this proves to impact, + // then in the future we could guard the cache call. + // The benefit to not guarding it is that changes made in + // the UI are appied immediately. + $config = Configuration::getInstance(); + $version = $config->http_user_agent_eveapi_version; + $config->http_user_agent = sprintf('SeAT %s/%s', $version, setting('admin_contact', true)); + $response = $this->instance->invoke($method, $uri, $uri_data); return new \Seat\Eveapi\Containers\EsiResponse(