Add patch notes and config endpoints

This commit is contained in:
Holden
2026-06-27 11:23:43 -05:00
parent b3028ce741
commit 2ea247a577
14 changed files with 427 additions and 3 deletions

View File

@@ -0,0 +1,8 @@
namespace API.Contracts.Builds.Responses;
public class LatestBuildsResponse
{
public string LatestWindowsVersion { get; set; } = "TBF";
public string LatestLinuxVersion { get; set; } = "TBF";
public string LatestMetaVersion { get; set; } = "TBF";
}

View File

@@ -0,0 +1,12 @@
using System.Text.Json.Serialization;
namespace API.Contracts.Config.Responses;
public class MediaPlayerConfigResponse
{
[JsonPropertyName("Enabled")]
public bool Enabled { get; set; }
[JsonPropertyName("Uri")]
public Uri? Uri { get; set; }
}

View File

@@ -0,0 +1,29 @@
using API.Contracts.Builds.Responses;
using Microsoft.AspNetCore.Mvc;
using RecNet.Application.Common.Interfaces;
using RecNet.Domain.PatchNotes;
namespace API.Controllers.Builds;
[ApiController]
[Route("api/[controller]/v1")]
public class BuildsController(IPatchNoteRepository patchNoteRepository, IConfigService configService) : ControllerBase
{
[HttpGet("latest")]
public async Task<ActionResult<LatestBuildsResponse>> GetLatestVersions(CancellationToken ct = default)
{
// If I didn't have a one-day deadline, I wouldn't be storing this as a server config.
// But I am, so this will have to do.
var latestBuilds = await configService.GetAsync(
"Builds:Latest",
new LatestBuildsResponse(),
ct);
return Ok(latestBuilds);
}
// rejecting DDD because I'm lazy :P
[HttpGet("patchNotes")]
public async Task<IReadOnlyList<PatchNote>> GetPatchNotes(CancellationToken ct = default)
=> await patchNoteRepository.GetAllAsync(ct);
}

View File

@@ -1,17 +1,34 @@
using API.Contracts.Config.Responses;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using RecNet.Application.Common.Interfaces;
namespace API.Controllers.Config.V1;
[Route("api/[controller]/v1")]
[Authorize]
[ApiController]
[Route("api/[controller]/v1")]
public class ConfigController(IConfigService configService) : ControllerBase
{
[HttpGet("motd")]
public async Task<ActionResult<string>> GetMotd(CancellationToken ct = default)
{
var motd = await configService.GetAsync("Config:MOTD", "Ten Whole Years!", ct);
var motd = await configService.GetAsync(
"Config:MOTD",
"Ten Whole Years!",
ct);
return Ok(motd);
}
}
[HttpGet("media-player")]
public async Task<ActionResult<MediaPlayerConfigResponse>> GetMediaPlayerConfig(CancellationToken ct = default)
{
var motd = await configService.GetAsync(
"Config:MediaPlayerConfig",
new MediaPlayerConfigResponse(),
ct);
return Ok(motd);
}
}

View File

@@ -26,6 +26,7 @@ public class SettingsController(IProfileService profileService) : ControllerBase
{
var profileId = User.GetProfileId();
// It's like having CQRS at home!
var updated = await profileService.UpdatePlayerSettingAsync
(
profileId: profileId,