This commit is contained in:
JustArchi
2018-11-08 05:23:49 +01:00
parent 89973519bd
commit 0db344ff32
3 changed files with 16 additions and 16 deletions

View File

@@ -333,14 +333,18 @@ namespace ArchiSteamFarm {
internal bool SwitchLootingAllowed() => LootingAllowed = !LootingAllowed; 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); Version version = await ASF.Update(true).ConfigureAwait(false);
if ((version == null) || (version <= SharedInfo.Version)) { if (version == null) {
return (false, version); return (false, null);
}
if (SharedInfo.Version >= version) {
return (false, "V" + SharedInfo.Version + " ≥ V" + version);
} }
Utilities.InBackground(ASF.RestartOrExit); 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(); 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();

View File

@@ -2316,8 +2316,8 @@ namespace ArchiSteamFarm {
return null; return null;
} }
(bool success, Version version) = await Actions.Update().ConfigureAwait(false); (bool success, string message) = await Actions.Update().ConfigureAwait(false);
return FormatStaticResponse((success ? Strings.Success : Strings.WarningFailed) + " " + (version != null ? SharedInfo.Version >= version ? "V" + SharedInfo.Version + " ≥ V" + version : "V" + version : "")); return FormatStaticResponse((success ? Strings.Success : Strings.WarningFailed) + (!string.IsNullOrEmpty(message) ? " " + message : ""));
} }
private string ResponseVersion(ulong steamID) { private string ResponseVersion(ulong steamID) {

View File

@@ -103,19 +103,15 @@ namespace ArchiSteamFarm.IPC.Controllers.Api {
/// Makes ASF update itself. /// Makes ASF update itself.
/// </summary> /// </summary>
[HttpPost("Update")] [HttpPost("Update")]
[ProducesResponseType(typeof(GenericResponse<Version>), 200)] [ProducesResponseType(typeof(GenericResponse), 200)]
public async Task<ActionResult<GenericResponse<Version>>> UpdatePost() { public async Task<ActionResult<GenericResponse>> UpdatePost() {
(bool success, Version version) = await Actions.Update().ConfigureAwait(false); (bool success, string message) = await Actions.Update().ConfigureAwait(false);
GenericResponse<Version> response; if (string.IsNullOrEmpty(message)) {
message = success ? Strings.Success : Strings.WarningFailed;
if (!success && (version != null) && (SharedInfo.Version >= version)) {
response = new GenericResponse<Version>(false, "V" + SharedInfo.Version + " ≥ V" + version, version);
} else {
response = new GenericResponse<Version>(success, version);
} }
return Ok(response); return Ok(new GenericResponse(success, message));
} }
} }
} }