Skip to content

Commit 07ccbed

Browse files
committed
Switch from EConfirmationType to EMobileConfirmationType
1 parent 07227bd commit 07ccbed

File tree

7 files changed

+13
-24
lines changed

7 files changed

+13
-24
lines changed

ArchiSteamFarm.OfficialPlugins.ItemsMatcher/RemoteCommunication.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,7 +1467,7 @@ private async Task<bool> MatchActively(ImmutableHashSet<ListedUser> listedUsers,
14671467
pendingMobileTradeOfferIDs.UnionWith(mobileTradeOfferIDs);
14681468

14691469
if (pendingMobileTradeOfferIDs.Count >= MaxTradeOffersActive) {
1470-
(bool twoFactorSuccess, IReadOnlyCollection<Confirmation>? handledConfirmations, _) = await Bot.Actions.HandleTwoFactorAuthenticationConfirmations(true, Confirmation.EConfirmationType.Trade, pendingMobileTradeOfferIDs, true).ConfigureAwait(false);
1470+
(bool twoFactorSuccess, IReadOnlyCollection<Confirmation>? handledConfirmations, _) = await Bot.Actions.HandleTwoFactorAuthenticationConfirmations(true, EMobileConfirmationType.Trade, pendingMobileTradeOfferIDs, true).ConfigureAwait(false);
14711471

14721472
if (!twoFactorSuccess) {
14731473
Bot.ArchiLogger.LogGenericWarning(Localization.Strings.FormatActivelyMatchingSomeConfirmationsFailed(handledConfirmations?.Count ?? 0, pendingMobileTradeOfferIDs.Count));
@@ -1563,7 +1563,7 @@ private async Task<bool> MatchActively(ImmutableHashSet<ListedUser> listedUsers,
15631563
}
15641564

15651565
if (pendingMobileTradeOfferIDs.Count > 0) {
1566-
(bool twoFactorSuccess, IReadOnlyCollection<Confirmation>? handledConfirmations, _) = Bot.IsConnectedAndLoggedOn ? await Bot.Actions.HandleTwoFactorAuthenticationConfirmations(true, Confirmation.EConfirmationType.Trade, pendingMobileTradeOfferIDs, true).ConfigureAwait(false) : (false, null, null);
1566+
(bool twoFactorSuccess, IReadOnlyCollection<Confirmation>? handledConfirmations, _) = Bot.IsConnectedAndLoggedOn ? await Bot.Actions.HandleTwoFactorAuthenticationConfirmations(true, EMobileConfirmationType.Trade, pendingMobileTradeOfferIDs, true).ConfigureAwait(false) : (false, null, null);
15671567

15681568
if (!twoFactorSuccess) {
15691569
Bot.ArchiLogger.LogGenericWarning(Localization.Strings.FormatActivelyMatchingSomeConfirmationsFailed(handledConfirmations?.Count ?? 0, pendingMobileTradeOfferIDs.Count));

ArchiSteamFarm/IPC/Controllers/Api/TwoFactorAuthenticationController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
using ArchiSteamFarm.Steam.Security;
3737
using Microsoft.AspNetCore.Http;
3838
using Microsoft.AspNetCore.Mvc;
39+
using SteamKit2;
3940

4041
namespace ArchiSteamFarm.IPC.Controllers.Api;
4142

@@ -74,7 +75,7 @@ public async Task<ActionResult<GenericResponse>> ConfirmationsPost([Description(
7475
ArgumentException.ThrowIfNullOrEmpty(botNames);
7576
ArgumentNullException.ThrowIfNull(request);
7677

77-
if (request.AcceptedType.HasValue && ((request.AcceptedType.Value == Confirmation.EConfirmationType.Unknown) || !Enum.IsDefined(request.AcceptedType.Value))) {
78+
if (request.AcceptedType.HasValue && ((request.AcceptedType.Value == EMobileConfirmationType.Invalid) || !Enum.IsDefined(request.AcceptedType.Value))) {
7879
return BadRequest(new GenericResponse(false, Strings.FormatErrorIsInvalid(nameof(request.AcceptedType))));
7980
}
8081

ArchiSteamFarm/IPC/Requests/TwoFactorAuthenticationConfirmationsRequest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
using ArchiSteamFarm.Core;
3434
using ArchiSteamFarm.Helpers.Json;
3535
using ArchiSteamFarm.Localization;
36-
using ArchiSteamFarm.Steam.Data;
36+
using SteamKit2;
3737

3838
namespace ArchiSteamFarm.IPC.Requests;
3939

@@ -52,7 +52,7 @@ public sealed class TwoFactorAuthenticationConfirmationsRequest {
5252

5353
[Description("Specifies the type of confirmations to handle. If not provided, all confirmation types are considered for an action")]
5454
[JsonInclude]
55-
public Confirmation.EConfirmationType? AcceptedType { get; private init; }
55+
public EMobileConfirmationType? AcceptedType { get; private init; }
5656

5757
[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")]
5858
[JsonDisallowNull]

ArchiSteamFarm/Steam/Data/Confirmation.cs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
using System.Diagnostics.CodeAnalysis;
2525
using System.Text.Json.Serialization;
2626
using JetBrains.Annotations;
27+
using SteamKit2;
2728

2829
namespace ArchiSteamFarm.Steam.Data;
2930

@@ -33,7 +34,7 @@ public sealed class Confirmation {
3334
[JsonInclude]
3435
[JsonPropertyName("type")]
3536
[JsonRequired]
36-
public EConfirmationType ConfirmationType { get; private init; }
37+
public EMobileConfirmationType ConfirmationType { get; private init; }
3738

3839
[JsonInclude]
3940
[JsonPropertyName("type_name")]
@@ -62,18 +63,4 @@ private Confirmation() { }
6263

6364
[UsedImplicitly]
6465
public static bool ShouldSerializeNonce() => false;
65-
66-
[PublicAPI]
67-
public enum EConfirmationType : byte {
68-
Unknown,
69-
Generic,
70-
Trade,
71-
Market,
72-
FeatureOptOut,
73-
PhoneNumberChange,
74-
AccountRecovery,
75-
ApiKeyRegistration = 9,
76-
FamilyJoin = 11,
77-
AccountSecurity = 12
78-
}
7966
}

ArchiSteamFarm/Steam/Exchange/Trading.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ private async Task<bool> ParseActiveTrades() {
303303
if (mobileTradeResults.Count > 0) {
304304
HashSet<ulong> mobileTradeOfferIDs = mobileTradeResults.Select(static tradeOffer => tradeOffer.TradeOfferID).ToHashSet();
305305

306-
(bool twoFactorSuccess, _, _) = await Bot.Actions.HandleTwoFactorAuthenticationConfirmations(true, Confirmation.EConfirmationType.Trade, mobileTradeOfferIDs, true).ConfigureAwait(false);
306+
(bool twoFactorSuccess, _, _) = await Bot.Actions.HandleTwoFactorAuthenticationConfirmations(true, EMobileConfirmationType.Trade, mobileTradeOfferIDs, true).ConfigureAwait(false);
307307

308308
if (twoFactorSuccess) {
309309
foreach (ParseTradeResult mobileTradeResult in mobileTradeResults) {

ArchiSteamFarm/Steam/Interaction/Actions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public async Task<IDisposable> GetTradingLock() {
217217
}
218218

219219
[PublicAPI]
220-
public async Task<(bool Success, IReadOnlyCollection<Confirmation>? HandledConfirmations, string Message)> HandleTwoFactorAuthenticationConfirmations(bool accept, Confirmation.EConfirmationType? acceptedType = null, IReadOnlyCollection<ulong>? acceptedCreatorIDs = null, bool waitIfNeeded = false) {
220+
public async Task<(bool Success, IReadOnlyCollection<Confirmation>? HandledConfirmations, string Message)> HandleTwoFactorAuthenticationConfirmations(bool accept, EMobileConfirmationType? acceptedType = null, IReadOnlyCollection<ulong>? acceptedCreatorIDs = null, bool waitIfNeeded = false) {
221221
if (Bot.BotDatabase.MobileAuthenticator == null) {
222222
return (false, null, Strings.BotNoASFAuthenticator);
223223
}
@@ -468,7 +468,7 @@ public static (bool Success, string Message) Restart() {
468468
(bool success, _, HashSet<ulong>? mobileTradeOfferIDs) = await Bot.ArchiWebHandler.SendTradeOffer(targetSteamID, items, token: tradeToken, customMessage: customMessage, itemsPerTrade: itemsPerTrade).ConfigureAwait(false);
469469

470470
if ((mobileTradeOfferIDs?.Count > 0) && Bot.HasMobileAuthenticator) {
471-
(bool twoFactorSuccess, _, _) = await HandleTwoFactorAuthenticationConfirmations(true, Confirmation.EConfirmationType.Trade, mobileTradeOfferIDs, true).ConfigureAwait(false);
471+
(bool twoFactorSuccess, _, _) = await HandleTwoFactorAuthenticationConfirmations(true, EMobileConfirmationType.Trade, mobileTradeOfferIDs, true).ConfigureAwait(false);
472472

473473
if (!twoFactorSuccess) {
474474
return (false, Strings.BotLootingFailed);

ArchiSteamFarm/Steam/Security/MobileAuthenticator.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
using ArchiSteamFarm.Localization;
3939
using ArchiSteamFarm.Steam.Data;
4040
using ArchiSteamFarm.Storage;
41+
using SteamKit2;
4142

4243
namespace ArchiSteamFarm.Steam.Security;
4344

@@ -175,7 +176,7 @@ public sealed class MobileAuthenticator : IDisposable {
175176
return null;
176177
}
177178

178-
foreach (Confirmation confirmation in response.Confirmations.Where(static confirmation => (confirmation.ConfirmationType == Confirmation.EConfirmationType.Unknown) || !Enum.IsDefined(confirmation.ConfirmationType))) {
179+
foreach (Confirmation confirmation in response.Confirmations.Where(static confirmation => (confirmation.ConfirmationType == EMobileConfirmationType.Invalid) || !Enum.IsDefined(confirmation.ConfirmationType))) {
179180
Bot.ArchiLogger.LogGenericError(Strings.FormatWarningUnknownValuePleaseReport(nameof(confirmation.ConfirmationType), $"{confirmation.ConfirmationType} ({confirmation.ConfirmationTypeName ?? "null"})"));
180181
}
181182

0 commit comments

Comments
 (0)