From c5f6cf0080bea913f7330b2fa7daff9c729c447d Mon Sep 17 00:00:00 2001 From: Dmitry Popov Date: Sat, 7 Jun 2025 01:47:03 +0200 Subject: [PATCH] fix(Core): fixed refresh character tokens --- .github/workflows/build.yml | 1 - lib/wanderer_app/character/tracker.ex | 12 ++++-------- .../character/transactions_tracker_impl.ex | 12 ++++++++---- lib/wanderer_app/esi/api_client.ex | 10 +++++++--- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f77352d2..77f7963a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -116,7 +116,6 @@ jobs: matrix: platform: - linux/amd64 - - linux/arm64 steps: - name: Prepare run: | diff --git a/lib/wanderer_app/character/tracker.ex b/lib/wanderer_app/character/tracker.ex index 9ac2e2d6..2bcab464 100644 --- a/lib/wanderer_app/character/tracker.ex +++ b/lib/wanderer_app/character/tracker.ex @@ -129,8 +129,7 @@ defmodule WandererApp.Character.Tracker do _ -> case WandererApp.Esi.get_character_online(eve_id, access_token: access_token, - character_id: character_id, - refresh_token?: true + character_id: character_id ) do {:ok, online} -> online = get_online(online) @@ -331,8 +330,7 @@ defmodule WandererApp.Character.Tracker do _ -> case WandererApp.Esi.get_character_ship(eve_id, access_token: access_token, - character_id: character_id, - refresh_token?: true + character_id: character_id ) do {:ok, ship} when is_non_struct_map(ship) -> character_state |> maybe_update_ship(ship) @@ -415,8 +413,7 @@ defmodule WandererApp.Character.Tracker do _ -> case WandererApp.Esi.get_character_location(eve_id, access_token: access_token, - character_id: character_id, - refresh_token?: true + character_id: character_id ) do {:ok, location} when is_non_struct_map(location) -> character_state @@ -505,8 +502,7 @@ defmodule WandererApp.Character.Tracker do case WandererApp.Esi.get_character_wallet(eve_id, params: %{datasource: "tranquility"}, access_token: access_token, - character_id: character_id, - refresh_token?: true + character_id: character_id ) do {:ok, result} -> {:ok, state} = WandererApp.Character.get_character_state(character_id) diff --git a/lib/wanderer_app/character/transactions_tracker_impl.ex b/lib/wanderer_app/character/transactions_tracker_impl.ex index af34386d..7cac7e74 100644 --- a/lib/wanderer_app/character/transactions_tracker_impl.ex +++ b/lib/wanderer_app/character/transactions_tracker_impl.ex @@ -145,13 +145,15 @@ defmodule WandererApp.Character.TransactionsTracker.Impl do end defp get_wallet_journal( - %{corporation_id: corporation_id, access_token: access_token} = _character, + %{id: character_id, corporation_id: corporation_id, access_token: access_token} = + _character, division ) when not is_nil(access_token) do case WandererApp.Esi.get_corporation_wallet_journal(corporation_id, division, params: %{datasource: "tranquility"}, - access_token: access_token + access_token: access_token, + character_id: character_id ) do {:ok, result} -> {:corporation_wallet_journal, result} @@ -173,12 +175,14 @@ defmodule WandererApp.Character.TransactionsTracker.Impl do defp get_wallet_journal(_character, _division), do: {:error, :skipped} defp update_corp_wallets( - %{corporation_id: corporation_id, access_token: access_token} = _character + %{id: character_id, corporation_id: corporation_id, access_token: access_token} = + _character ) when not is_nil(access_token) do case WandererApp.Esi.get_corporation_wallets(corporation_id, params: %{datasource: "tranquility"}, - access_token: access_token + access_token: access_token, + character_id: character_id ) do {:ok, result} -> {:corporation_wallets, result} diff --git a/lib/wanderer_app/esi/api_client.ex b/lib/wanderer_app/esi/api_client.ex index 0c7a39a2..853b743b 100644 --- a/lib/wanderer_app/esi/api_client.ex +++ b/lib/wanderer_app/esi/api_client.ex @@ -463,10 +463,10 @@ defmodule WandererApp.Esi.ApiClient do get( path, auth_opts, - opts + opts |> with_refresh_token() ) else - get_retry(path, auth_opts, opts) + get_retry(path, auth_opts, opts |> with_refresh_token()) end end @@ -485,7 +485,7 @@ defmodule WandererApp.Esi.ApiClient do "/corporations/#{corporation_eve_id}/#{info_path}", [params: opts[:params] || []] ++ (opts |> get_auth_opts()), - opts ++ @cache_opts + (opts |> with_refresh_token()) ++ @cache_opts ) defp with_user_agent_opts(opts) do @@ -495,6 +495,10 @@ defmodule WandererApp.Esi.ApiClient do ) end + defp with_refresh_token(opts) do + opts |> Keyword.merge(refresh_token?: true) + end + defp with_cache_opts(opts) do opts |> Keyword.merge(@cache_opts) |> Keyword.merge(cache_dir: System.tmp_dir!()) end