mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 14:10:53 +00:00
Resolve trade offers being stuck for too long when ASF API connection is down
This commit is contained in:
@@ -184,7 +184,13 @@ internal static class ArchiNet {
|
||||
|
||||
Uri request = new(URL, "/Api/BadBots");
|
||||
|
||||
ObjectResponse<GenericResponse<ImmutableHashSet<ulong>>>? response = await ASF.WebBrowser.UrlGetToJsonObject<GenericResponse<ImmutableHashSet<ulong>>>(request, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
ObjectResponse<GenericResponse<ImmutableHashSet<ulong>>>? response = null;
|
||||
|
||||
try {
|
||||
response = await ASF.WebBrowser.UrlGetToJsonObject<GenericResponse<ImmutableHashSet<ulong>>>(request, cancellationToken: cancellationToken).ConfigureAwait(false);
|
||||
} catch (OperationCanceledException e) {
|
||||
ASF.ArchiLogger.LogGenericDebuggingException(e);
|
||||
}
|
||||
|
||||
if (response?.Content?.Result == null) {
|
||||
return (false, ASF.GlobalDatabase.CachedBadBots);
|
||||
|
||||
@@ -396,7 +396,10 @@ public sealed class Trading : IDisposable {
|
||||
|
||||
// Deny trades from bad steamIDs if user wishes to do so
|
||||
if (ASF.GlobalConfig?.FilterBadBots ?? GlobalConfig.DefaultFilterBadBots) {
|
||||
bool? isBadBot = await ArchiNet.IsBadBot(tradeOffer.OtherSteamID64).ConfigureAwait(false);
|
||||
// Allow no longer than 10 seconds timeout for BadBot call, as we don't want to hold the trade offer for too long
|
||||
using CancellationTokenSource cts = new(TimeSpan.FromSeconds(10));
|
||||
|
||||
bool? isBadBot = await ArchiNet.IsBadBot(tradeOffer.OtherSteamID64, cts.Token).ConfigureAwait(false);
|
||||
|
||||
if (isBadBot == true) {
|
||||
Bot.ArchiLogger.LogGenericDebug(string.Format(CultureInfo.CurrentCulture, Strings.BotTradeOfferResult, tradeOffer.TradeOfferID, ParseTradeResult.EResult.Blacklisted, $"{nameof(tradeOffer.OtherSteamID64)} {tradeOffer.OtherSteamID64}"));
|
||||
|
||||
Reference in New Issue
Block a user