From 0db344ff32524fa6a2e425efe7ae11e315594a4a Mon Sep 17 00:00:00 2001 From: JustArchi Date: Thu, 8 Nov 2018 05:23:49 +0100 Subject: [PATCH] Misc --- ArchiSteamFarm/Actions.cs | 12 ++++++++---- ArchiSteamFarm/Commands.cs | 4 ++-- .../IPC/Controllers/Api/ASFController.cs | 16 ++++++---------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/ArchiSteamFarm/Actions.cs b/ArchiSteamFarm/Actions.cs index 3371c57e8..f513f9f07 100644 --- a/ArchiSteamFarm/Actions.cs +++ b/ArchiSteamFarm/Actions.cs @@ -333,14 +333,18 @@ namespace ArchiSteamFarm { internal bool SwitchLootingAllowed() => LootingAllowed = !LootingAllowed; - internal static async Task<(bool Success, Version Version)> Update() { + internal static async Task<(bool Success, string Message)> Update() { Version version = await ASF.Update(true).ConfigureAwait(false); - if ((version == null) || (version <= SharedInfo.Version)) { - return (false, version); + if (version == null) { + return (false, null); + } + + if (SharedInfo.Version >= version) { + return (false, "V" + SharedInfo.Version + " ≥ V" + version); } Utilities.InBackground(ASF.RestartOrExit); - return (true, version); + return (true, version.ToString()); } private ulong GetFirstSteamMasterID() => Bot.BotConfig.SteamUserPermissions.Where(kv => (kv.Key != 0) && (kv.Value == BotConfig.EPermission.Master)).Select(kv => kv.Key).OrderByDescending(steamID => steamID != Bot.SteamID).ThenBy(steamID => steamID).FirstOrDefault(); diff --git a/ArchiSteamFarm/Commands.cs b/ArchiSteamFarm/Commands.cs index 52eeaa086..477917039 100644 --- a/ArchiSteamFarm/Commands.cs +++ b/ArchiSteamFarm/Commands.cs @@ -2316,8 +2316,8 @@ namespace ArchiSteamFarm { return null; } - (bool success, Version version) = await Actions.Update().ConfigureAwait(false); - return FormatStaticResponse((success ? Strings.Success : Strings.WarningFailed) + " " + (version != null ? SharedInfo.Version >= version ? "V" + SharedInfo.Version + " ≥ V" + version : "V" + version : "")); + (bool success, string message) = await Actions.Update().ConfigureAwait(false); + return FormatStaticResponse((success ? Strings.Success : Strings.WarningFailed) + (!string.IsNullOrEmpty(message) ? " " + message : "")); } private string ResponseVersion(ulong steamID) { diff --git a/ArchiSteamFarm/IPC/Controllers/Api/ASFController.cs b/ArchiSteamFarm/IPC/Controllers/Api/ASFController.cs index d4b99b5da..63de0341c 100644 --- a/ArchiSteamFarm/IPC/Controllers/Api/ASFController.cs +++ b/ArchiSteamFarm/IPC/Controllers/Api/ASFController.cs @@ -103,19 +103,15 @@ namespace ArchiSteamFarm.IPC.Controllers.Api { /// Makes ASF update itself. /// [HttpPost("Update")] - [ProducesResponseType(typeof(GenericResponse), 200)] - public async Task>> UpdatePost() { - (bool success, Version version) = await Actions.Update().ConfigureAwait(false); + [ProducesResponseType(typeof(GenericResponse), 200)] + public async Task> UpdatePost() { + (bool success, string message) = await Actions.Update().ConfigureAwait(false); - GenericResponse response; - - if (!success && (version != null) && (SharedInfo.Version >= version)) { - response = new GenericResponse(false, "V" + SharedInfo.Version + " ≥ V" + version, version); - } else { - response = new GenericResponse(success, version); + if (string.IsNullOrEmpty(message)) { + message = success ? Strings.Success : Strings.WarningFailed; } - return Ok(response); + return Ok(new GenericResponse(success, message)); } } }