From ca2109d3d76ba1f676058148d0bece34b183d88d Mon Sep 17 00:00:00 2001 From: JustArchi Date: Fri, 16 Aug 2019 16:37:55 +0200 Subject: [PATCH] Open TradingLock and API key check for public --- ArchiSteamFarm/Actions.cs | 15 ++++++++------- ArchiSteamFarm/ArchiWebHandler.cs | 13 +++++++------ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/ArchiSteamFarm/Actions.cs b/ArchiSteamFarm/Actions.cs index 160c78848..7fce3948d 100644 --- a/ArchiSteamFarm/Actions.cs +++ b/ArchiSteamFarm/Actions.cs @@ -79,6 +79,14 @@ namespace ArchiSteamFarm { return (true, token, Strings.Success); } + [ItemNotNull] + [PublicAPI] + public async Task GetTradingLock() { + await TradingSemaphore.WaitAsync().ConfigureAwait(false); + + return new SemaphoreLock(TradingSemaphore); + } + [PublicAPI] public async Task<(bool Success, string Message)> HandleTwoFactorAuthenticationConfirmations(bool accept, Steam.ConfirmationDetails.EType? acceptedType = null, IReadOnlyCollection acceptedTradeOfferIDs = null, bool waitIfNeeded = false) { if (!Bot.HasMobileAuthenticator) { @@ -413,13 +421,6 @@ namespace ArchiSteamFarm { } } - [ItemNotNull] - internal async Task GetTradingLock() { - await TradingSemaphore.WaitAsync().ConfigureAwait(false); - - return new SemaphoreLock(TradingSemaphore); - } - internal void OnDisconnected() => HandledGifts.Clear(); private ulong GetFirstSteamMasterID() => Bot.BotConfig.SteamUserPermissions.Where(kv => (kv.Key != 0) && (kv.Value == BotConfig.EPermission.Master)).Select(kv => kv.Key).OrderByDescending(steamID => steamID != Bot.SteamID).ThenBy(steamID => steamID).FirstOrDefault(); diff --git a/ArchiSteamFarm/ArchiWebHandler.cs b/ArchiSteamFarm/ArchiWebHandler.cs index 4c6f1b512..43ea16639 100644 --- a/ArchiSteamFarm/ArchiWebHandler.cs +++ b/ArchiSteamFarm/ArchiWebHandler.cs @@ -354,6 +354,13 @@ namespace ArchiSteamFarm { return result; } + [PublicAPI] + public async Task HasValidApiKey() { + (bool success, string steamApiKey) = await CachedApiKey.GetValue().ConfigureAwait(false); + + return success ? !string.IsNullOrEmpty(steamApiKey) : (bool?) null; + } + [PublicAPI] public async Task<(bool Success, HashSet MobileTradeOfferIDs)> SendTradeOffer(ulong steamID, IReadOnlyCollection itemsToGive = null, IReadOnlyCollection itemsToReceive = null, string token = null, bool forcedSingleOffer = false) { if ((steamID == 0) || !new SteamID(steamID).IsIndividualAccount || (((itemsToGive == null) || (itemsToGive.Count == 0)) && ((itemsToReceive == null) || (itemsToReceive.Count == 0)))) { @@ -2000,12 +2007,6 @@ namespace ArchiSteamFarm { return success ? hasPublicInventory : (bool?) null; } - internal async Task HasValidApiKey() { - (bool success, string steamApiKey) = await CachedApiKey.GetValue().ConfigureAwait(false); - - return success ? !string.IsNullOrEmpty(steamApiKey) : (bool?) null; - } - internal async Task Init(ulong steamID, EUniverse universe, string webAPIUserNonce, string parentalCode = null) { if ((steamID == 0) || !new SteamID(steamID).IsIndividualAccount || (universe == EUniverse.Invalid) || !Enum.IsDefined(typeof(EUniverse), universe) || string.IsNullOrEmpty(webAPIUserNonce)) { Bot.ArchiLogger.LogNullError(nameof(steamID) + " || " + nameof(universe) + " || " + nameof(webAPIUserNonce));