diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2021-09-09 21:16:40 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-09 21:16:40 -0500 |
| commit | 583325356493c0123a6410e6aa34e60bf148f219 (patch) | |
| tree | f12cc20285998bbdf5d3313c621429f8096c87ea /src/slskd/Application/Management/API/Controllers/ApplicationController.cs | |
| parent | 3d645132c2613bcd376ec710e6d1d02e9912cf15 (diff) | |
| parent | eae8db1aecdae631edc0f2d370d3c704d49c58b9 (diff) | |
| download | slskd-583325356493c0123a6410e6aa34e60bf148f219.tar.gz | |
Merge pull request #191 from slskd/version-check
Add a version check on startup, and elements to the UI to indicate when a new version is available
Diffstat (limited to 'src/slskd/Application/Management/API/Controllers/ApplicationController.cs')
| -rw-r--r-- | src/slskd/Application/Management/API/Controllers/ApplicationController.cs | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/slskd/Application/Management/API/Controllers/ApplicationController.cs b/src/slskd/Application/Management/API/Controllers/ApplicationController.cs index dd115786..b3d43300 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; @@ -33,12 +34,14 @@ namespace slskd.Management.API [Consumes("application/json")] public class ApplicationController : ControllerBase { - public ApplicationController(IManagementService managementService, IHostApplicationLifetime lifetime) + public ApplicationController(IManagementService managementService, IHostApplicationLifetime lifetime, IApplication application) { Management = managementService; Lifetime = lifetime; + Application = application; } + private IApplication Application { get; } private IManagementService Management { get; } private IHostApplicationLifetime Lifetime { get; } @@ -78,5 +81,33 @@ namespace slskd.Management.API return NoContent(); } + + /// <summary> + /// Gets the current application version. + /// </summary> + /// <returns></returns> + [HttpGet("version")] + [Authorize] + public IActionResult GetVersion() + { + return Ok(Program.InformationalVersion); + } + + /// <summary> + /// Checks for updates. + /// </summary> + /// <returns></returns> + [HttpGet("version/latest")] + [Authorize] + public async Task<IActionResult> CheckVersion([FromQuery]bool forceCheck = false) + { + if (forceCheck) + { + await Application.CheckVersionAsync(); + } + + var state = Management.ApplicationState; + return Ok(state.Version); + } } } |
