aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Application/Management/API/Controllers
diff options
context:
space:
mode:
authorJP Dillingham <jpdillingham@gmail.com>2021-09-09 21:16:40 -0500
committerGitHub <noreply@github.com>2021-09-09 21:16:40 -0500
commit583325356493c0123a6410e6aa34e60bf148f219 (patch)
treef12cc20285998bbdf5d3313c621429f8096c87ea /src/slskd/Application/Management/API/Controllers
parent3d645132c2613bcd376ec710e6d1d02e9912cf15 (diff)
parenteae8db1aecdae631edc0f2d370d3c704d49c58b9 (diff)
downloadslskd-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')
-rw-r--r--src/slskd/Application/Management/API/Controllers/ApplicationController.cs33
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);
+ }
}
}