Switch from EConfirmationType to EMobileConfirmationType

This commit is contained in:
Łukasz Domeradzki
2026-01-15 00:24:04 +01:00
parent 07227bd7e2
commit 07ccbedfe7
7 changed files with 13 additions and 24 deletions

View File

@@ -1467,7 +1467,7 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable {
pendingMobileTradeOfferIDs.UnionWith(mobileTradeOfferIDs);
if (pendingMobileTradeOfferIDs.Count >= MaxTradeOffersActive) {
(bool twoFactorSuccess, IReadOnlyCollection<Confirmation>? handledConfirmations, _) = await Bot.Actions.HandleTwoFactorAuthenticationConfirmations(true, Confirmation.EConfirmationType.Trade, pendingMobileTradeOfferIDs, true).ConfigureAwait(false);
(bool twoFactorSuccess, IReadOnlyCollection<Confirmation>? handledConfirmations, _) = await Bot.Actions.HandleTwoFactorAuthenticationConfirmations(true, EMobileConfirmationType.Trade, pendingMobileTradeOfferIDs, true).ConfigureAwait(false);
if (!twoFactorSuccess) {
Bot.ArchiLogger.LogGenericWarning(Localization.Strings.FormatActivelyMatchingSomeConfirmationsFailed(handledConfirmations?.Count ?? 0, pendingMobileTradeOfferIDs.Count));
@@ -1563,7 +1563,7 @@ internal sealed class RemoteCommunication : IAsyncDisposable, IDisposable {
}
if (pendingMobileTradeOfferIDs.Count > 0) {
(bool twoFactorSuccess, IReadOnlyCollection<Confirmation>? handledConfirmations, _) = Bot.IsConnectedAndLoggedOn ? await Bot.Actions.HandleTwoFactorAuthenticationConfirmations(true, Confirmation.EConfirmationType.Trade, pendingMobileTradeOfferIDs, true).ConfigureAwait(false) : (false, null, null);
(bool twoFactorSuccess, IReadOnlyCollection<Confirmation>? handledConfirmations, _) = Bot.IsConnectedAndLoggedOn ? await Bot.Actions.HandleTwoFactorAuthenticationConfirmations(true, EMobileConfirmationType.Trade, pendingMobileTradeOfferIDs, true).ConfigureAwait(false) : (false, null, null);
if (!twoFactorSuccess) {
Bot.ArchiLogger.LogGenericWarning(Localization.Strings.FormatActivelyMatchingSomeConfirmationsFailed(handledConfirmations?.Count ?? 0, pendingMobileTradeOfferIDs.Count));

View File

@@ -36,6 +36,7 @@ using ArchiSteamFarm.Steam.Data;
using ArchiSteamFarm.Steam.Security;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SteamKit2;
namespace ArchiSteamFarm.IPC.Controllers.Api;
@@ -74,7 +75,7 @@ public sealed class TwoFactorAuthenticationController : ArchiController {
ArgumentException.ThrowIfNullOrEmpty(botNames);
ArgumentNullException.ThrowIfNull(request);
if (request.AcceptedType.HasValue && ((request.AcceptedType.Value == Confirmation.EConfirmationType.Unknown) || !Enum.IsDefined(request.AcceptedType.Value))) {
if (request.AcceptedType.HasValue && ((request.AcceptedType.Value == EMobileConfirmationType.Invalid) || !Enum.IsDefined(request.AcceptedType.Value))) {
return BadRequest(new GenericResponse(false, Strings.FormatErrorIsInvalid(nameof(request.AcceptedType))));
}

View File

@@ -33,7 +33,7 @@ using System.Text.Json.Serialization;
using ArchiSteamFarm.Core;
using ArchiSteamFarm.Helpers.Json;
using ArchiSteamFarm.Localization;
using ArchiSteamFarm.Steam.Data;
using SteamKit2;
namespace ArchiSteamFarm.IPC.Requests;
@@ -52,7 +52,7 @@ public sealed class TwoFactorAuthenticationConfirmationsRequest {
[Description("Specifies the type of confirmations to handle. If not provided, all confirmation types are considered for an action")]
[JsonInclude]
public Confirmation.EConfirmationType? AcceptedType { get; private init; }
public EMobileConfirmationType? AcceptedType { get; private init; }
[Description($"A helper property which works the same as {nameof(AcceptedCreatorIDs)} but with values written as strings - for javascript compatibility purposes. Use either this one, or {nameof(AcceptedCreatorIDs)}, not both")]
[JsonDisallowNull]

View File

@@ -24,6 +24,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
using JetBrains.Annotations;
using SteamKit2;
namespace ArchiSteamFarm.Steam.Data;
@@ -33,7 +34,7 @@ public sealed class Confirmation {
[JsonInclude]
[JsonPropertyName("type")]
[JsonRequired]
public EConfirmationType ConfirmationType { get; private init; }
public EMobileConfirmationType ConfirmationType { get; private init; }
[JsonInclude]
[JsonPropertyName("type_name")]
@@ -62,18 +63,4 @@ public sealed class Confirmation {
[UsedImplicitly]
public static bool ShouldSerializeNonce() => false;
[PublicAPI]
public enum EConfirmationType : byte {
Unknown,
Generic,
Trade,
Market,
FeatureOptOut,
PhoneNumberChange,
AccountRecovery,
ApiKeyRegistration = 9,
FamilyJoin = 11,
AccountSecurity = 12
}
}

View File

@@ -303,7 +303,7 @@ public sealed class Trading : IDisposable {
if (mobileTradeResults.Count > 0) {
HashSet<ulong> mobileTradeOfferIDs = mobileTradeResults.Select(static tradeOffer => tradeOffer.TradeOfferID).ToHashSet();
(bool twoFactorSuccess, _, _) = await Bot.Actions.HandleTwoFactorAuthenticationConfirmations(true, Confirmation.EConfirmationType.Trade, mobileTradeOfferIDs, true).ConfigureAwait(false);
(bool twoFactorSuccess, _, _) = await Bot.Actions.HandleTwoFactorAuthenticationConfirmations(true, EMobileConfirmationType.Trade, mobileTradeOfferIDs, true).ConfigureAwait(false);
if (twoFactorSuccess) {
foreach (ParseTradeResult mobileTradeResult in mobileTradeResults) {

View File

@@ -217,7 +217,7 @@ public sealed class Actions : IAsyncDisposable, IDisposable {
}
[PublicAPI]
public async Task<(bool Success, IReadOnlyCollection<Confirmation>? HandledConfirmations, string Message)> HandleTwoFactorAuthenticationConfirmations(bool accept, Confirmation.EConfirmationType? acceptedType = null, IReadOnlyCollection<ulong>? acceptedCreatorIDs = null, bool waitIfNeeded = false) {
public async Task<(bool Success, IReadOnlyCollection<Confirmation>? HandledConfirmations, string Message)> HandleTwoFactorAuthenticationConfirmations(bool accept, EMobileConfirmationType? acceptedType = null, IReadOnlyCollection<ulong>? acceptedCreatorIDs = null, bool waitIfNeeded = false) {
if (Bot.BotDatabase.MobileAuthenticator == null) {
return (false, null, Strings.BotNoASFAuthenticator);
}
@@ -468,7 +468,7 @@ public sealed class Actions : IAsyncDisposable, IDisposable {
(bool success, _, HashSet<ulong>? mobileTradeOfferIDs) = await Bot.ArchiWebHandler.SendTradeOffer(targetSteamID, items, token: tradeToken, customMessage: customMessage, itemsPerTrade: itemsPerTrade).ConfigureAwait(false);
if ((mobileTradeOfferIDs?.Count > 0) && Bot.HasMobileAuthenticator) {
(bool twoFactorSuccess, _, _) = await HandleTwoFactorAuthenticationConfirmations(true, Confirmation.EConfirmationType.Trade, mobileTradeOfferIDs, true).ConfigureAwait(false);
(bool twoFactorSuccess, _, _) = await HandleTwoFactorAuthenticationConfirmations(true, EMobileConfirmationType.Trade, mobileTradeOfferIDs, true).ConfigureAwait(false);
if (!twoFactorSuccess) {
return (false, Strings.BotLootingFailed);

View File

@@ -38,6 +38,7 @@ using ArchiSteamFarm.Helpers;
using ArchiSteamFarm.Localization;
using ArchiSteamFarm.Steam.Data;
using ArchiSteamFarm.Storage;
using SteamKit2;
namespace ArchiSteamFarm.Steam.Security;
@@ -175,7 +176,7 @@ public sealed class MobileAuthenticator : IDisposable {
return null;
}
foreach (Confirmation confirmation in response.Confirmations.Where(static confirmation => (confirmation.ConfirmationType == Confirmation.EConfirmationType.Unknown) || !Enum.IsDefined(confirmation.ConfirmationType))) {
foreach (Confirmation confirmation in response.Confirmations.Where(static confirmation => (confirmation.ConfirmationType == EMobileConfirmationType.Invalid) || !Enum.IsDefined(confirmation.ConfirmationType))) {
Bot.ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(confirmation.ConfirmationType), $"{confirmation.ConfirmationType} ({confirmation.ConfirmationTypeName ?? "null"})"));
}