Update Notification Refactor (#511)

* Replaced profile links to anchors so we can open in new tab if we like

* Refactored how update checking works. We now explicitly check and send back on the same API. We have a weekly job that will push an update to the user.

* Implemented a changelog tab

* Ported over a GA fix for using ' in PR bodies.

* Don't check cert for Github
This commit is contained in:
Joseph Milazzo 2021-08-19 16:49:53 -07:00 committed by GitHub
parent 0e48aeebc5
commit 2a76092566
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 246 additions and 56 deletions

View file

@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using API.DTOs.Stats;
using API.DTOs.Update;
using API.Extensions;
using API.Interfaces;
using API.Interfaces.Services;
@ -25,9 +27,11 @@ namespace API.Controllers
private readonly IArchiveService _archiveService;
private readonly ICacheService _cacheService;
private readonly ITaskScheduler _taskScheduler;
private readonly IVersionUpdaterService _versionUpdaterService;
public ServerController(IHostApplicationLifetime applicationLifetime, ILogger<ServerController> logger, IConfiguration config,
IBackupService backupService, IArchiveService archiveService, ICacheService cacheService, ITaskScheduler taskScheduler)
IBackupService backupService, IArchiveService archiveService, ICacheService cacheService, ITaskScheduler taskScheduler,
IVersionUpdaterService versionUpdaterService)
{
_applicationLifetime = applicationLifetime;
_logger = logger;
@ -36,6 +40,7 @@ namespace API.Controllers
_archiveService = archiveService;
_cacheService = cacheService;
_taskScheduler = taskScheduler;
_versionUpdaterService = versionUpdaterService;
}
/// <summary>
@ -102,11 +107,16 @@ namespace API.Controllers
}
}
[HttpPost("check-update")]
public ActionResult CheckForUpdates()
[HttpGet("check-update")]
public async Task<ActionResult<UpdateNotificationDto>> CheckForUpdates()
{
_taskScheduler.CheckForUpdate();
return Ok();
return Ok(await _versionUpdaterService.CheckForUpdate());
}
[HttpGet("changelog")]
public async Task<ActionResult<IEnumerable<UpdateNotificationDto>>> GetChangelog()
{
return Ok(await _versionUpdaterService.GetAllReleases());
}
}
}