From fed8c8a705810c4a4c2c1a89e7c93d55b621269d Mon Sep 17 00:00:00 2001 From: JustArchi Date: Sat, 13 Oct 2018 02:18:19 +0200 Subject: [PATCH] Handle partial confirmations in a retry --- ArchiSteamFarm/Actions.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ArchiSteamFarm/Actions.cs b/ArchiSteamFarm/Actions.cs index 1552d058f..27b17e430 100644 --- a/ArchiSteamFarm/Actions.cs +++ b/ArchiSteamFarm/Actions.cs @@ -55,7 +55,7 @@ namespace ArchiSteamFarm { CardsFarmerResumeTimer?.Dispose(); } - internal async Task AcceptConfirmations(bool accept, Steam.ConfirmationDetails.EType acceptedType = Steam.ConfirmationDetails.EType.Unknown, ulong acceptedSteamID = 0, IReadOnlyCollection acceptedTradeIDs = null, bool waitIfNeeded = false) { + internal async Task AcceptConfirmations(bool accept, Steam.ConfirmationDetails.EType acceptedType = Steam.ConfirmationDetails.EType.Unknown, ulong acceptedSteamID = 0, ISet acceptedTradeOfferIDs = null, bool waitIfNeeded = false) { if (!Bot.HasMobileAuthenticator) { return false; } @@ -70,13 +70,13 @@ namespace ArchiSteamFarm { continue; } - if ((acceptedSteamID == 0) && ((acceptedTradeIDs == null) || (acceptedTradeIDs.Count == 0))) { + if ((acceptedSteamID == 0) && ((acceptedTradeOfferIDs == null) || (acceptedTradeOfferIDs.Count == 0))) { return await Bot.BotDatabase.MobileAuthenticator.HandleConfirmations(confirmations, accept).ConfigureAwait(false); } IList results = await Utilities.InParallel(confirmations.Select(Bot.BotDatabase.MobileAuthenticator.GetConfirmationDetails)).ConfigureAwait(false); - foreach (MobileAuthenticator.Confirmation confirmation in results.Where(details => (details != null) && ((acceptedType != details.Type) || ((acceptedSteamID != 0) && (details.OtherSteamID64 != 0) && (acceptedSteamID != details.OtherSteamID64)) || ((acceptedTradeIDs != null) && (details.TradeOfferID != 0) && !acceptedTradeIDs.Contains(details.TradeOfferID)))).Select(details => details.Confirmation)) { + foreach (MobileAuthenticator.Confirmation confirmation in results.Where(details => (details != null) && ((acceptedType != details.Type) || ((acceptedSteamID != 0) && (details.OtherSteamID64 != 0) && (acceptedSteamID != details.OtherSteamID64)) || ((acceptedTradeOfferIDs != null) && (details.TradeOfferID != 0) && !acceptedTradeOfferIDs.Contains(details.TradeOfferID)))).Select(details => details.Confirmation)) { confirmations.Remove(confirmation); } @@ -84,7 +84,13 @@ namespace ArchiSteamFarm { continue; } - return await Bot.BotDatabase.MobileAuthenticator.HandleConfirmations(confirmations, accept).ConfigureAwait(false); + if (!await Bot.BotDatabase.MobileAuthenticator.HandleConfirmations(confirmations, accept).ConfigureAwait(false)) { + return false; + } + + if ((acceptedTradeOfferIDs == null) || (acceptedTradeOfferIDs.Count == 0) || results.Where(result => (result.TradeOfferID != 0) && confirmations.Contains(result.Confirmation)).Select(result => result.TradeOfferID).Where(acceptedTradeOfferIDs.Remove).Any(tradeOfferID => acceptedTradeOfferIDs.Count == 0)) { + return true; + } } return true;