Expose CanUpdate property in ASF API

This commit is contained in:
JustArchi
2020-10-18 20:29:56 +02:00
parent f0e6cdaecc
commit fe0df93176
2 changed files with 10 additions and 2 deletions

View File

@@ -66,7 +66,7 @@ namespace ArchiSteamFarm.IPC.Controllers.Api {
uint memoryUsage = (uint) GC.GetTotalMemory(false) / 1024;
ASFResponse result = new ASFResponse(SharedInfo.BuildInfo.Variant, ASF.GlobalConfig, memoryUsage, RuntimeCompatibility.ProcessStartTime, SharedInfo.Version);
ASFResponse result = new ASFResponse(SharedInfo.BuildInfo.Variant, SharedInfo.BuildInfo.CanUpdate, ASF.GlobalConfig, memoryUsage, RuntimeCompatibility.ProcessStartTime, SharedInfo.Version);
return Ok(new GenericResponse<ASFResponse>(result));
}

View File

@@ -32,6 +32,13 @@ namespace ArchiSteamFarm.IPC.Responses {
[Required]
public readonly string BuildVariant;
/// <summary>
/// A value specifying whether this variant of ASF is capable of auto-update.
/// </summary>
[JsonProperty(Required = Required.Always)]
[Required]
public readonly bool CanUpdate;
/// <summary>
/// Currently loaded ASF's global config.
/// </summary>
@@ -60,12 +67,13 @@ namespace ArchiSteamFarm.IPC.Responses {
[Required]
public readonly Version Version;
internal ASFResponse(string buildVariant, GlobalConfig globalConfig, uint memoryUsage, DateTime processStartTime, Version version) {
internal ASFResponse(string buildVariant, bool canUpdate, GlobalConfig globalConfig, uint memoryUsage, DateTime processStartTime, Version version) {
if (string.IsNullOrEmpty(buildVariant) || (globalConfig == null) || (memoryUsage == 0) || (processStartTime == DateTime.MinValue) || (version == null)) {
throw new ArgumentNullException(nameof(buildVariant) + " || " + nameof(globalConfig) + " || " + nameof(memoryUsage) + " || " + nameof(processStartTime) + " || " + nameof(version));
}
BuildVariant = buildVariant;
CanUpdate = canUpdate;
GlobalConfig = globalConfig;
MemoryUsage = memoryUsage;
ProcessStartTime = processStartTime;