diff options
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); + } } } |
