Files
2026-07-23 18:21:43 -07:00

52 lines
1.6 KiB
C#

using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.ComponentModel.DataAnnotations;
using System.Runtime.InteropServices;
namespace DeluxeBackend.Controllers.Api
{
[Route("api/versioncheck")]
[ApiController]
public class VersioncheckController : ControllerBase
{
[HttpGet("v1")]//this is for 2016 builds
public IActionResult V1([FromHeader(Name = "X-Rec-Room-Version")] string appVersion = "")
{
if (appVersion != ServerConfig.AppVersion)
{
return StatusCode(403);
}
return Ok();
}
[HttpGet("v2")]//this is for 2017/2018 builds
[HttpGet("v3")]
public IActionResult V3([FromQuery(Name = "v")] string appVersion = "")
{
return Ok(new
{
ValidVersion = appVersion == ServerConfig.AppVersion
});
}
[HttpGet("v4")]//this is for 2019 and later builds
public IActionResult V4([FromQuery(Name = "v"), Required] string appVersion, [FromQuery(Name = "p")] int? platform = null, [FromQuery(Name = "pid")] string? platformId = null)
{
int versionStatus = 0;
if (appVersion != ServerConfig.AppVersion)
{
versionStatus = 1;
}
return Ok(new
{
VersionStatus = versionStatus,
UpdateNotificationStage = 0,
IsVersionIslanded = false,
IsCrossPlayDisabled = false
});
}
}
}