Compare commits

...

4 Commits

Author SHA1 Message Date
Archi
d3aa881f55 Fix STD serialization after STJ changes 2024-02-23 02:42:18 +01:00
Archi
33a1fdf556 Misc 2024-02-23 01:18:09 +01:00
Archi
0c848ec366 Misc 2024-02-23 01:15:35 +01:00
Archi
21d4e46b81 Bump 2024-02-22 23:45:13 +01:00
5 changed files with 18 additions and 15 deletions

View File

@@ -30,17 +30,23 @@ using SteamKit2;
namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper.Data; namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper.Data;
internal sealed class SubmitRequest { internal sealed class SubmitRequest {
private readonly ulong SteamID;
[JsonInclude] [JsonInclude]
[JsonPropertyName("guid")] [JsonPropertyName("guid")]
private static string Guid => ASF.GlobalDatabase?.Identifier.ToString("N") ?? throw new InvalidOperationException(nameof(ASF.GlobalDatabase.Identifier)); private string Guid => ASF.GlobalDatabase?.Identifier.ToString("N") ?? throw new InvalidOperationException(nameof(ASF.GlobalDatabase.Identifier));
[JsonInclude]
[JsonPropertyName("steamid")]
private string SteamIDText => new SteamID(SteamID).Render();
[JsonInclude] [JsonInclude]
[JsonPropertyName("token")] [JsonPropertyName("token")]
private static string Token => SharedInfo.Token; private string Token => SharedInfo.Token;
[JsonInclude] [JsonInclude]
[JsonPropertyName("v")] [JsonPropertyName("v")]
private static byte Version => SharedInfo.ApiVersion; private byte Version => SharedInfo.ApiVersion;
[JsonInclude] [JsonInclude]
[JsonPropertyName("apps")] [JsonPropertyName("apps")]
@@ -52,17 +58,11 @@ internal sealed class SubmitRequest {
[JsonRequired] [JsonRequired]
private ImmutableDictionary<string, string> Depots { get; init; } private ImmutableDictionary<string, string> Depots { get; init; }
private readonly ulong SteamID;
[JsonInclude] [JsonInclude]
[JsonPropertyName("subs")] [JsonPropertyName("subs")]
[JsonRequired] [JsonRequired]
private ImmutableDictionary<string, string> Subs { get; init; } private ImmutableDictionary<string, string> Subs { get; init; }
[JsonInclude]
[JsonPropertyName("steamid")]
private string SteamIDText => new SteamID(SteamID).Render();
internal SubmitRequest(ulong steamID, IReadOnlyCollection<KeyValuePair<uint, ulong>> apps, IReadOnlyCollection<KeyValuePair<uint, ulong>> accessTokens, IReadOnlyCollection<KeyValuePair<uint, string>> depots) { internal SubmitRequest(ulong steamID, IReadOnlyCollection<KeyValuePair<uint, ulong>> apps, IReadOnlyCollection<KeyValuePair<uint, ulong>> accessTokens, IReadOnlyCollection<KeyValuePair<uint, string>> depots) {
if ((steamID == 0) || !new SteamID(steamID).IsIndividualAccount) { if ((steamID == 0) || !new SteamID(steamID).IsIndividualAccount) {
throw new ArgumentOutOfRangeException(nameof(steamID)); throw new ArgumentOutOfRangeException(nameof(steamID));

View File

@@ -53,7 +53,6 @@ namespace ArchiSteamFarm.OfficialPlugins.SteamTokenDumper;
internal sealed class SteamTokenDumperPlugin : OfficialPlugin, IASF, IBot, IBotCommand2, IBotSteamClient, ISteamPICSChanges { internal sealed class SteamTokenDumperPlugin : OfficialPlugin, IASF, IBot, IBotCommand2, IBotSteamClient, ISteamPICSChanges {
private const ushort DepotsRateLimitingDelay = 500; private const ushort DepotsRateLimitingDelay = 500;
[JsonInclude]
internal static SteamTokenDumperConfig? Config { get; private set; } internal static SteamTokenDumperConfig? Config { get; private set; }
private static readonly ConcurrentDictionary<Bot, IDisposable> BotSubscriptions = new(); private static readonly ConcurrentDictionary<Bot, IDisposable> BotSubscriptions = new();

View File

@@ -42,10 +42,10 @@ public static class JsonUtilities {
public static readonly JsonSerializerOptions IndentedJsonSerialierOptions = CreateDefaultJsonSerializerOptions(true); public static readonly JsonSerializerOptions IndentedJsonSerialierOptions = CreateDefaultJsonSerializerOptions(true);
[PublicAPI] [PublicAPI]
public static JsonElement ToJsonElement<T>(this T obj, bool writeIndented = false) where T : notnull { public static JsonElement ToJsonElement<T>(this T obj) where T : notnull {
ArgumentNullException.ThrowIfNull(obj); ArgumentNullException.ThrowIfNull(obj);
return JsonSerializer.SerializeToElement(obj, writeIndented ? IndentedJsonSerialierOptions : DefaultJsonSerialierOptions); return JsonSerializer.SerializeToElement(obj, DefaultJsonSerialierOptions);
} }
[PublicAPI] [PublicAPI]

View File

@@ -27,6 +27,7 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Reflection; using System.Reflection;
using System.Text.Json;
using ArchiSteamFarm.Core; using ArchiSteamFarm.Core;
using ArchiSteamFarm.Helpers.Json; using ArchiSteamFarm.Helpers.Json;
using ArchiSteamFarm.IPC.Integration; using ArchiSteamFarm.IPC.Integration;
@@ -328,8 +329,11 @@ internal sealed class Startup {
mvc.AddJsonOptions( mvc.AddJsonOptions(
static options => { static options => {
options.JsonSerializerOptions.PropertyNamingPolicy = JsonUtilities.DefaultJsonSerialierOptions.PropertyNamingPolicy; JsonSerializerOptions jsonSerializerOptions = Debugging.IsUserDebugging ? JsonUtilities.IndentedJsonSerialierOptions : JsonUtilities.DefaultJsonSerialierOptions;
options.JsonSerializerOptions.TypeInfoResolver = JsonUtilities.DefaultJsonSerialierOptions.TypeInfoResolver;
options.JsonSerializerOptions.PropertyNamingPolicy = jsonSerializerOptions.PropertyNamingPolicy;
options.JsonSerializerOptions.TypeInfoResolver = jsonSerializerOptions.TypeInfoResolver;
options.JsonSerializerOptions.WriteIndented = jsonSerializerOptions.WriteIndented;
} }
); );
} }

View File

@@ -1,6 +1,6 @@
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<Version>6.0.0.0</Version> <Version>6.0.0.1</Version>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>