mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-16 08:25:28 +00:00
General code cleanups
This commit is contained in:
@@ -301,8 +301,7 @@ internal static class ArchiKestrel {
|
||||
}
|
||||
|
||||
// Add support for proxies
|
||||
services.Configure<ForwardedHeadersOptions>(
|
||||
options => {
|
||||
services.Configure<ForwardedHeadersOptions>(options => {
|
||||
options.ForwardedHeaders = ForwardedHeaders.All;
|
||||
|
||||
if (knownNetworks != null) {
|
||||
@@ -351,8 +350,7 @@ internal static class ArchiKestrel {
|
||||
}
|
||||
}
|
||||
|
||||
services.ConfigureHttpJsonOptions(
|
||||
static options => {
|
||||
services.ConfigureHttpJsonOptions(static options => {
|
||||
JsonSerializerOptions jsonSerializerOptions = Debugging.IsUserDebugging ? JsonUtilities.IndentedJsonSerialierOptions : JsonUtilities.DefaultJsonSerialierOptions;
|
||||
|
||||
options.SerializerOptions.PropertyNamingPolicy = jsonSerializerOptions.PropertyNamingPolicy;
|
||||
@@ -377,8 +375,7 @@ internal static class ArchiKestrel {
|
||||
mvc.AddControllersAsServices();
|
||||
|
||||
// Modify default JSON options
|
||||
mvc.AddJsonOptions(
|
||||
static options => {
|
||||
mvc.AddJsonOptions(static options => {
|
||||
JsonSerializerOptions jsonSerializerOptions = Debugging.IsUserDebugging ? JsonUtilities.IndentedJsonSerialierOptions : JsonUtilities.DefaultJsonSerialierOptions;
|
||||
|
||||
options.JsonSerializerOptions.PropertyNamingPolicy = jsonSerializerOptions.PropertyNamingPolicy;
|
||||
@@ -439,8 +436,7 @@ internal static class ArchiKestrel {
|
||||
builder.WebHost.UseConfiguration(new ConfigurationBuilder().SetBasePath(absoluteConfigDirectory).AddJsonFile(SharedInfo.IPCConfigFile, false, true).Build());
|
||||
}
|
||||
|
||||
builder.WebHost.ConfigureKestrel(
|
||||
options => {
|
||||
builder.WebHost.ConfigureKestrel(options => {
|
||||
options.AddServerHeader = false;
|
||||
|
||||
if (customConfigExists) {
|
||||
|
||||
@@ -279,30 +279,6 @@ public sealed class BotController : ArchiController {
|
||||
return Ok(results.All(static result => result) ? new GenericResponse(true) : new GenericResponse(false, Strings.WarningFailed));
|
||||
}
|
||||
|
||||
[EndpointSummary("Fetches general inventory information of given bots")]
|
||||
[HttpGet("{botNames:required}/Inventory")]
|
||||
[ProducesResponseType<GenericResponse<IReadOnlyDictionary<string, ImmutableDictionary<uint, InventoryAppData>>>>((int) HttpStatusCode.OK)]
|
||||
[ProducesResponseType<GenericResponse>((int) HttpStatusCode.BadRequest)]
|
||||
public async Task<ActionResult<GenericResponse>> InventoryInfoGet(string botNames) {
|
||||
ArgumentException.ThrowIfNullOrEmpty(botNames);
|
||||
|
||||
HashSet<Bot>? bots = Bot.GetBots(botNames);
|
||||
|
||||
if ((bots == null) || (bots.Count == 0)) {
|
||||
return BadRequest(new GenericResponse(false, Strings.FormatBotNotFound(botNames)));
|
||||
}
|
||||
|
||||
IList<ImmutableDictionary<uint, InventoryAppData>?> results = await Utilities.InParallel(bots.Select(static bot => bot.ArchiWebHandler.GetInventoryContextData())).ConfigureAwait(false);
|
||||
|
||||
Dictionary<string, ImmutableDictionary<uint, InventoryAppData>?> result = new(bots.Count, Bot.BotsComparer);
|
||||
|
||||
foreach (Bot bot in bots) {
|
||||
result[bot.BotName] = results[result.Count];
|
||||
}
|
||||
|
||||
return Ok(new GenericResponse<IReadOnlyDictionary<string, ImmutableDictionary<uint, InventoryAppData>?>>(result));
|
||||
}
|
||||
|
||||
[EndpointSummary("Fetches specific inventory of given bots")]
|
||||
[HttpGet("{botNames:required}/Inventory/{appID}/{contextID}")]
|
||||
[ProducesResponseType<GenericResponse<IReadOnlyDictionary<string, BotInventoryResponse>>>((int) HttpStatusCode.OK)]
|
||||
@@ -354,6 +330,30 @@ public sealed class BotController : ArchiController {
|
||||
return Ok(new GenericResponse<IReadOnlyDictionary<string, BotInventoryResponse>>(result));
|
||||
}
|
||||
|
||||
[EndpointSummary("Fetches general inventory information of given bots")]
|
||||
[HttpGet("{botNames:required}/Inventory")]
|
||||
[ProducesResponseType<GenericResponse<IReadOnlyDictionary<string, ImmutableDictionary<uint, InventoryAppData>>>>((int) HttpStatusCode.OK)]
|
||||
[ProducesResponseType<GenericResponse>((int) HttpStatusCode.BadRequest)]
|
||||
public async Task<ActionResult<GenericResponse>> InventoryInfoGet(string botNames) {
|
||||
ArgumentException.ThrowIfNullOrEmpty(botNames);
|
||||
|
||||
HashSet<Bot>? bots = Bot.GetBots(botNames);
|
||||
|
||||
if ((bots == null) || (bots.Count == 0)) {
|
||||
return BadRequest(new GenericResponse(false, Strings.FormatBotNotFound(botNames)));
|
||||
}
|
||||
|
||||
IList<ImmutableDictionary<uint, InventoryAppData>?> results = await Utilities.InParallel(bots.Select(static bot => bot.ArchiWebHandler.GetInventoryContextData())).ConfigureAwait(false);
|
||||
|
||||
Dictionary<string, ImmutableDictionary<uint, InventoryAppData>?> result = new(bots.Count, Bot.BotsComparer);
|
||||
|
||||
foreach (Bot bot in bots) {
|
||||
result[bot.BotName] = results[result.Count];
|
||||
}
|
||||
|
||||
return Ok(new GenericResponse<IReadOnlyDictionary<string, ImmutableDictionary<uint, InventoryAppData>?>>(result));
|
||||
}
|
||||
|
||||
[EndpointSummary("Pauses given bots")]
|
||||
[HttpPost("{botNames:required}/Pause")]
|
||||
[ProducesResponseType<GenericResponse>((int) HttpStatusCode.OK)]
|
||||
|
||||
@@ -52,7 +52,7 @@ internal sealed class OperationTransformer : IOpenApiOperationTransformer {
|
||||
}
|
||||
},
|
||||
|
||||
Array.Empty<string>()
|
||||
[]
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user