From c7f63e0468c0ca034986d8c72627f9a02040ba43 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Mon, 6 Sep 2021 22:12:57 -0500 Subject: add CheckVersionAsync --- .../API/Controllers/ApplicationController.cs | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/slskd/Application/Management/API/Controllers') diff --git a/src/slskd/Application/Management/API/Controllers/ApplicationController.cs b/src/slskd/Application/Management/API/Controllers/ApplicationController.cs index dd115786..850dfda9 100644 --- a/src/slskd/Application/Management/API/Controllers/ApplicationController.cs +++ b/src/slskd/Application/Management/API/Controllers/ApplicationController.cs @@ -19,6 +19,7 @@ namespace slskd.Management.API { using System; using System.Diagnostics; + using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Hosting; @@ -78,5 +79,33 @@ namespace slskd.Management.API return NoContent(); } + + /// + /// Gets the current application version. + /// + /// + [HttpGet("version")] + [Authorize] + public IActionResult GetVersion() + { + return Ok(Program.InformationalVersion); + } + + /// + /// Checks for updates. + /// + /// + [HttpGet("version/latest")] + [Authorize] + public async Task CheckVersion([FromQuery]bool forceCheck = false) + { + if (forceCheck) + { + await Management.CheckVersionAsync(); + } + + var state = Management.ApplicationState; + return Ok(new CheckVersionResponse() { UpdateAvailable = state.UpdateAvailable, LatestVersion = state.LatestVersion }); + } } } -- cgit v1.2.3