diff --git a/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/Backend.cs b/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/Backend.cs index 5a1016e8c83c6..047b6befa9889 100644 --- a/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/Backend.cs +++ b/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/Backend.cs @@ -114,6 +114,21 @@ internal static string GenerateChecksumFor(IList assetsForListi return Utilities.GenerateChecksumFor(bytes); } + internal static async Task GetLicenseStatus(Guid licenseID, WebBrowser webBrowser) { + ArgumentOutOfRangeException.ThrowIfEqual(licenseID, Guid.Empty); + ArgumentNullException.ThrowIfNull(webBrowser); + + Uri request = new(ArchiNet.URL, "/Api/Licenses/Status"); + + Dictionary headers = new(1, StringComparer.Ordinal) { + { "X-License-Key", licenseID.ToString("N") } + }; + + ObjectResponse? response = await webBrowser.UrlGetToJsonObject(request, headers, requestOptions: WebBrowser.ERequestOptions.ReturnClientErrors | WebBrowser.ERequestOptions.AllowInvalidBodyOnErrors).ConfigureAwait(false); + + return response?.StatusCode; + } + internal static async Task<(HttpStatusCode StatusCode, ImmutableHashSet Users)?> GetListedUsersForMatching(Guid licenseID, Bot bot, WebBrowser webBrowser, IReadOnlyCollection inventory, IReadOnlyCollection acceptedMatchableTypes) { ArgumentOutOfRangeException.ThrowIfEqual(licenseID, Guid.Empty); ArgumentNullException.ThrowIfNull(bot); diff --git a/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs b/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs index cb496feff6759..6d07da6c9104f 100644 --- a/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs +++ b/ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs @@ -920,6 +920,20 @@ private async void MatchActively(object? state = null) { try { Bot.ArchiLogger.LogGenericInfo(Strings.Starting); + HttpStatusCode? licenseStatus = await Backend.GetLicenseStatus(ASF.GlobalConfig.LicenseID.Value, WebBrowser).ConfigureAwait(false); + + if (licenseStatus == null) { + Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, nameof(licenseStatus))); + + return; + } + + if (!licenseStatus.Value.IsSuccessCode()) { + Bot.ArchiLogger.LogGenericWarning(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, licenseStatus.Value)); + + return; + } + HashSet assetsForMatching; try {