From 3abc12f4bcd6af0673d1add3a1569fc9dd1032d8 Mon Sep 17 00:00:00 2001 From: achiez Date: Wed, 9 Jul 2025 22:19:21 +0300 Subject: [PATCH] Add support to new confirmation type (Purchase) and improve localization and snackbars --- src/NebulaAuth/App.xaml | 27 ++++++++++++++++--- src/NebulaAuth/Core/SnackbarController.cs | 2 +- src/NebulaAuth/Model/MAAC/PortableMaClient.cs | 3 ++- src/NebulaAuth/Model/Shell.cs | 1 + src/NebulaAuth/PlannedChanges.txt | 3 ++- .../View/ConfirmationTemplates.xaml | 27 +++++++++++++++++++ src/NebulaAuth/localization.loc.json | 19 ++++++++----- .../AccountRecoveryConfirmation.cs | 2 +- .../Concrete[folder]/Confirmation.cs | 4 +-- .../Concrete[folder]/MarketConfirmation.cs | 2 +- .../Concrete[folder]/PurchaseConfirmation.cs | 8 ++++++ .../RegisterApiKeyConfirmation.cs | 2 +- .../Concrete[folder]/TradeConfirmation.cs | 4 +-- .../Confirmations/ConfirmationType.cs | 3 ++- .../Web/Models/Mobile/Confirmations.cs | 2 +- .../JSON/MobileConfirmationScrapper.cs | 10 +++++++ 16 files changed, 97 insertions(+), 22 deletions(-) create mode 100644 src/SteamLibForked/SteamMobile/Confirmations/Concrete[folder]/PurchaseConfirmation.cs diff --git a/src/NebulaAuth/App.xaml b/src/NebulaAuth/App.xaml index 190151e..1253945 100644 --- a/src/NebulaAuth/App.xaml +++ b/src/NebulaAuth/App.xaml @@ -7,11 +7,32 @@ xmlns:background="clr-namespace:NebulaAuth.Converters.Background"> - + + + + + + + + + + + + + + + + + + + + + True + False + - @@ -38,7 +59,7 @@ - + diff --git a/src/NebulaAuth/Core/SnackbarController.cs b/src/NebulaAuth/Core/SnackbarController.cs index 8404c7f..976822c 100644 --- a/src/NebulaAuth/Core/SnackbarController.cs +++ b/src/NebulaAuth/Core/SnackbarController.cs @@ -44,7 +44,7 @@ public class SnackbarController private static TimeSpan GetSnackbarTime(string str) { - var duration = str.Length / 0.03; + var duration = str.Length / 0.022; if (duration < MIN_SNACKBAR_TIME) { duration = MIN_SNACKBAR_TIME; diff --git a/src/NebulaAuth/Model/MAAC/PortableMaClient.cs b/src/NebulaAuth/Model/MAAC/PortableMaClient.cs index 3b8298f..33dd601 100644 --- a/src/NebulaAuth/Model/MAAC/PortableMaClient.cs +++ b/src/NebulaAuth/Model/MAAC/PortableMaClient.cs @@ -90,7 +90,8 @@ public partial class PortableMaClient : ObservableObject, IDisposable var toConfirm = new List(); if (AutoConfirmMarket) { - var market = conf.Where(c => c.ConfType == ConfirmationType.MarketSellTransaction); + var market = conf.Where(c => + c.ConfType is ConfirmationType.MarketSellTransaction or ConfirmationType.Purchase); toConfirm.AddRange(market); } diff --git a/src/NebulaAuth/Model/Shell.cs b/src/NebulaAuth/Model/Shell.cs index 21dbf7c..f9d598a 100644 --- a/src/NebulaAuth/Model/Shell.cs +++ b/src/NebulaAuth/Model/Shell.cs @@ -40,5 +40,6 @@ public static class Shell private static void CurrentDomainOnUnhandledException(object sender, UnhandledExceptionEventArgs e) { Logger.Fatal((Exception) e.ExceptionObject); + LogManager.Shutdown(); } } \ No newline at end of file diff --git a/src/NebulaAuth/PlannedChanges.txt b/src/NebulaAuth/PlannedChanges.txt index d800fe0..a38bff5 100644 --- a/src/NebulaAuth/PlannedChanges.txt +++ b/src/NebulaAuth/PlannedChanges.txt @@ -10,4 +10,5 @@ • Антик-окно как в MarketApp, возможность сразу открыть браузер напр. на CefSharp с залогиненым аккаунтом • Стабильность авто-подтверждений, возможность задать пользователю порог времени когда льются ошибки и только тогда выключать авто-подтверждение • Безопасное сохранение мафайлов через .tmp / .bak -• Создание механизма накопления ошибок, чтобы исправить Patch Tuesday, условно аккаунт может игнорировать ошибки 1-2 часа (настриавемо) \ No newline at end of file +• Создание механизма накопления ошибок, чтобы исправить Patch Tuesday, условно аккаунт может игнорировать ошибки 1-2 часа (настриавемо) + diff --git a/src/NebulaAuth/View/ConfirmationTemplates.xaml b/src/NebulaAuth/View/ConfirmationTemplates.xaml index 083cb72..9568309 100644 --- a/src/NebulaAuth/View/ConfirmationTemplates.xaml +++ b/src/NebulaAuth/View/ConfirmationTemplates.xaml @@ -207,4 +207,31 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/NebulaAuth/localization.loc.json b/src/NebulaAuth/localization.loc.json index f11ccc1..db25661 100644 --- a/src/NebulaAuth/localization.loc.json +++ b/src/NebulaAuth/localization.loc.json @@ -255,7 +255,12 @@ "en": "Market", "ru": "Маркет", "ua": "Маркет" - } + }, + "Purchase": { + "en": "Purchase", + "ru": "Покупка", + "ua": "Покупка" + } }, "CodeCopied": { "ru": "Скопировано", @@ -1098,14 +1103,14 @@ }, "ExceptionHandler": { "SessionInvalidException": { - "ru": "Сессия истекла. Попробуйте обновить ее через меню или залогиниться заново", - "en": "Session expired. Try to refresh it through menu or login again", - "ua": "Сесія прострочена. Спробуйте оновити її через меню або залогінитися знову" + "ru": "Сессия истекла. Попробуйте обновить ее или залогиниться заново (Аккаунт → войти)", + "en": "Session expired. Try to refresh it or login again (Account → Login)", + "ua": "Сесія прострочена. Спробуйте оновити її через меню або залогінитися знову (Акаунт → Увійти)" }, "SessionExpiredException": { - "ru": "Сессия полностью истекла. Нужно залогиниться заново", - "en": "Session fully expired. Need to login again", - "ua": "Сесія повніст'ю прострочена'. Потрібно залогінитися знову" + "ru": "Сессия полностью истекла. Нужно залогиниться заново (Аккаунт → Войти)", + "en": "Session fully expired. Need to login again (Account → Login)", + "ua": "Сесія повніст'ю прострочена'. Потрібно залогінитися знову (Акаунт → Увійти)" }, "TaskCanceledException": { "ru": "Произошла отмена операции", diff --git a/src/SteamLibForked/SteamMobile/Confirmations/Concrete[folder]/AccountRecoveryConfirmation.cs b/src/SteamLibForked/SteamMobile/Confirmations/Concrete[folder]/AccountRecoveryConfirmation.cs index c7ba356..53ce210 100644 --- a/src/SteamLibForked/SteamMobile/Confirmations/Concrete[folder]/AccountRecoveryConfirmation.cs +++ b/src/SteamLibForked/SteamMobile/Confirmations/Concrete[folder]/AccountRecoveryConfirmation.cs @@ -2,7 +2,7 @@ public class AccountRecoveryConfirmation : Confirmation { - public AccountRecoveryConfirmation(long id, ulong nonce, long creator, string typeName) : base(id, nonce, 6, + public AccountRecoveryConfirmation(long id, ulong nonce, ulong creator, string typeName) : base(id, nonce, 6, creator, ConfirmationType.AccountRecovery, typeName) { } diff --git a/src/SteamLibForked/SteamMobile/Confirmations/Concrete[folder]/Confirmation.cs b/src/SteamLibForked/SteamMobile/Confirmations/Concrete[folder]/Confirmation.cs index 0c0a2f9..8d5c460 100644 --- a/src/SteamLibForked/SteamMobile/Confirmations/Concrete[folder]/Confirmation.cs +++ b/src/SteamLibForked/SteamMobile/Confirmations/Concrete[folder]/Confirmation.cs @@ -12,7 +12,7 @@ public class Confirmation /// /// Represents either the Trade Offer ID or market transaction ID that caused this confirmation to be created. /// - public long CreatorId { get; } + public ulong CreatorId { get; } public string TypeName { get; init; } public string HeadLine { get; init; } = string.Empty; @@ -31,7 +31,7 @@ public class Confirmation /// public int IntType; - public Confirmation(long id, ulong nonce, int intType, long creatorId, ConfirmationType confType, string typeName) + public Confirmation(long id, ulong nonce, int intType, ulong creatorId, ConfirmationType confType, string typeName) { Id = id; Nonce = nonce; diff --git a/src/SteamLibForked/SteamMobile/Confirmations/Concrete[folder]/MarketConfirmation.cs b/src/SteamLibForked/SteamMobile/Confirmations/Concrete[folder]/MarketConfirmation.cs index ffea8c4..f4a607d 100644 --- a/src/SteamLibForked/SteamMobile/Confirmations/Concrete[folder]/MarketConfirmation.cs +++ b/src/SteamLibForked/SteamMobile/Confirmations/Concrete[folder]/MarketConfirmation.cs @@ -6,7 +6,7 @@ public class MarketConfirmation : Confirmation public string ItemName { get; init; } = string.Empty; public string PriceString { get; init; } = string.Empty; - public MarketConfirmation(long id, ulong key, long creator, string typeName) : base(id, key, 3, creator, + public MarketConfirmation(long id, ulong key, ulong creator, string typeName) : base(id, key, 3, creator, ConfirmationType.MarketSellTransaction, typeName) { } diff --git a/src/SteamLibForked/SteamMobile/Confirmations/Concrete[folder]/PurchaseConfirmation.cs b/src/SteamLibForked/SteamMobile/Confirmations/Concrete[folder]/PurchaseConfirmation.cs new file mode 100644 index 0000000..158d1e4 --- /dev/null +++ b/src/SteamLibForked/SteamMobile/Confirmations/Concrete[folder]/PurchaseConfirmation.cs @@ -0,0 +1,8 @@ +namespace SteamLib.SteamMobile.Confirmations; + +public class PurchaseConfirmation : Confirmation +{ + public PurchaseConfirmation(long id, ulong nonce, int intType, ulong creatorId, string typeName) : base(id, nonce, intType, creatorId, ConfirmationType.Purchase, typeName) + { + } +} \ No newline at end of file diff --git a/src/SteamLibForked/SteamMobile/Confirmations/Concrete[folder]/RegisterApiKeyConfirmation.cs b/src/SteamLibForked/SteamMobile/Confirmations/Concrete[folder]/RegisterApiKeyConfirmation.cs index 74457b5..6217acf 100644 --- a/src/SteamLibForked/SteamMobile/Confirmations/Concrete[folder]/RegisterApiKeyConfirmation.cs +++ b/src/SteamLibForked/SteamMobile/Confirmations/Concrete[folder]/RegisterApiKeyConfirmation.cs @@ -2,7 +2,7 @@ public class RegisterApiKeyConfirmation : Confirmation { - public RegisterApiKeyConfirmation(long id, ulong nonce, long creatorId, string typeName) : base(id, nonce, 8, + public RegisterApiKeyConfirmation(long id, ulong nonce, ulong creatorId, string typeName) : base(id, nonce, 8, creatorId, ConfirmationType.RegisterApiKey, typeName) { } diff --git a/src/SteamLibForked/SteamMobile/Confirmations/Concrete[folder]/TradeConfirmation.cs b/src/SteamLibForked/SteamMobile/Confirmations/Concrete[folder]/TradeConfirmation.cs index 468dad2..4952022 100644 --- a/src/SteamLibForked/SteamMobile/Confirmations/Concrete[folder]/TradeConfirmation.cs +++ b/src/SteamLibForked/SteamMobile/Confirmations/Concrete[folder]/TradeConfirmation.cs @@ -7,9 +7,9 @@ public class TradeConfirmation : Confirmation public bool IsReceiveNothing { get; set; } public override TradeConfirmationDetails? Details { get; } - public long TradeId => CreatorId; + public ulong TradeId => CreatorId; - public TradeConfirmation(long id, ulong nonce, long creator, string typeName) : base(id, nonce, 1, creator, + public TradeConfirmation(long id, ulong nonce, ulong creator, string typeName) : base(id, nonce, 1, creator, ConfirmationType.Trade, typeName) { } diff --git a/src/SteamLibForked/SteamMobile/Confirmations/ConfirmationType.cs b/src/SteamLibForked/SteamMobile/Confirmations/ConfirmationType.cs index 4196840..09f0e92 100644 --- a/src/SteamLibForked/SteamMobile/Confirmations/ConfirmationType.cs +++ b/src/SteamLibForked/SteamMobile/Confirmations/ConfirmationType.cs @@ -6,5 +6,6 @@ public enum ConfirmationType Trade = 2, MarketSellTransaction = 3, AccountRecovery = 6, - RegisterApiKey = 9 + RegisterApiKey = 9, + Purchase = 12 } \ No newline at end of file diff --git a/src/SteamLibForked/Web/Models/Mobile/Confirmations.cs b/src/SteamLibForked/Web/Models/Mobile/Confirmations.cs index fe2c242..0ee2e60 100644 --- a/src/SteamLibForked/Web/Models/Mobile/Confirmations.cs +++ b/src/SteamLibForked/Web/Models/Mobile/Confirmations.cs @@ -23,7 +23,7 @@ public class ConfirmationJson [JsonProperty("type")] public ConfirmationType Type { get; set; } [JsonProperty("type_name")] public string TypeName { get; set; } = string.Empty; [JsonProperty("id")] public long Id { get; set; } - [JsonProperty("creator_id")] public long CreatorId { get; set; } + [JsonProperty("creator_id")] public ulong CreatorId { get; set; } [JsonProperty("nonce")] public ulong Nonce { get; set; } [JsonProperty("creation_time")] public UnixTimeStamp CreationTime { get; set; } [JsonProperty("cancel")] public string Cancel { get; set; } = string.Empty; diff --git a/src/SteamLibForked/Web/Scrappers/JSON/MobileConfirmationScrapper.cs b/src/SteamLibForked/Web/Scrappers/JSON/MobileConfirmationScrapper.cs index 65476ef..da20b34 100644 --- a/src/SteamLibForked/Web/Scrappers/JSON/MobileConfirmationScrapper.cs +++ b/src/SteamLibForked/Web/Scrappers/JSON/MobileConfirmationScrapper.cs @@ -77,6 +77,7 @@ public static class MobileConfirmationScrapper ConfirmationType.AccountRecovery => GetAccountRecoveryConfirmation(json), ConfirmationType.MarketSellTransaction => GetMarketConfirmation(json), ConfirmationType.RegisterApiKey => GetRegisterApiKeyConfirmation(json), + ConfirmationType.Purchase => GetPurchaseConfirmation(json), _ => new Confirmation(json.Id, json.Nonce, (int) json.Type, json.CreatorId, json.Type, json.TypeName) { Time = json.CreationTime.ToLocalDateTime() @@ -166,4 +167,13 @@ public static class MobileConfirmationScrapper PriceString = string.Empty //TODO: }; } + + private static PurchaseConfirmation GetPurchaseConfirmation(ConfirmationJson confirmation) + { + return new PurchaseConfirmation(confirmation.Id, confirmation.Nonce, (int) confirmation.Type, + confirmation.CreatorId, confirmation.TypeName) + { + Time = confirmation.CreationTime.ToLocalDateTime() + }; + } } \ No newline at end of file