diff --git a/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/Backend.cs b/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/Backend.cs index 57f91fe2e..eb74cc701 100644 --- a/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/Backend.cs +++ b/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/Backend.cs @@ -95,15 +95,13 @@ internal static class Backend { return (response.StatusCode, response.Content?.Result ?? ImmutableHashSet.Empty); } - internal static async Task HeartBeatForListing(Bot bot) { + internal static async Task HeartBeatForListing(Bot bot) { ArgumentNullException.ThrowIfNull(bot); Uri request = new(ArchiNet.URL, "/Api/Listing/HeartBeat"); HeartBeatRequest data = new(ASF.GlobalDatabase?.Identifier ?? Guid.NewGuid(), bot.SteamID); - BasicResponse? response = await bot.ArchiWebHandler.WebBrowser.UrlPost(request, data: data, requestOptions: WebBrowser.ERequestOptions.ReturnClientErrors).ConfigureAwait(false); - - return response?.StatusCode; + return await bot.ArchiWebHandler.WebBrowser.UrlPost(request, data: data, requestOptions: WebBrowser.ERequestOptions.ReturnRedirections | WebBrowser.ERequestOptions.ReturnClientErrors).ConfigureAwait(false); } } diff --git a/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs b/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs index 3ff9e0470..882d3d808 100644 --- a/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs +++ b/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs @@ -327,13 +327,29 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable { } try { - HttpStatusCode? response = await Backend.HeartBeatForListing(Bot).ConfigureAwait(false); + BasicResponse? response = await Backend.HeartBeatForListing(Bot).ConfigureAwait(false); - if (!response.HasValue) { + if (response == null) { + // This is actually a network failure, we should keep sending heartbeats for now return; } - if (response.Value.IsClientErrorCode()) { + if (response.StatusCode.IsRedirectionCode()) { + ShouldSendHeartBeats = false; + + if (response.FinalUri.Host != ArchiWebHandler.SteamCommunityURL.Host) { + ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(response.FinalUri), response.FinalUri)); + + return; + } + + // We've expected the result, not the redirection to the sign in, we need to authenticate again + SignedInWithSteam = false; + + return; + } + + if (response.StatusCode.IsClientErrorCode()) { ShouldSendHeartBeats = false; return;