feat: Add support for 2018 client API endpoints and data models

- Implemented new search endpoints for rooms to accommodate the 2018 client.
- Added support for retrieving room details and featured rooms in a format compatible with the 2018 client.
- Introduced new data models for login responses and player presence specific to the 2018 client.
- Created mappers to convert between internal entities and the 2018 wire formats for players and rooms.
- Updated existing storefront APIs to include versioned endpoints for the 2018 client.
- Enhanced the version controller to return dual-format responses for compatibility with both 2018 and 2020 clients.
- Refactored the configuration service to ensure trailing slashes in URLs for the 2018 client.
This commit is contained in:
Alexa
2026-06-07 15:32:52 +03:00
parent 955246c6e4
commit 579071858a
21 changed files with 770 additions and 94 deletions
@@ -0,0 +1,35 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using DorkNet.Models.Players;
using DorkNet.Server.Services;
namespace DorkNet.Server.Controllers.API.Presence;
/// <summary>
/// api/presence/* — the June-2018 client's friend-presence poll (every ~30s,
/// RecNet.cs:63249). POST api/presence/v2/list takes a JSON array of account
/// ids and returns one <see cref="Presence2018"/> per id. There is no 2020
/// equivalent on this host (the 2020 client used match.rec.net/player), so this
/// controller is 2018-specific. Online state comes from
/// <see cref="OnlinePresenceService"/>; GameSession is left null for now (the
/// client renders "online" without it and fills in room info on join).
/// </summary>
[ApiController]
[Authorize]
public class PresenceController(OnlinePresenceService presence) : ControllerBase
{
[HttpPost("/api/presence/v2/list")]
[HttpPost("/api/presence/v1/list")]
public ActionResult<List<Presence2018>> List([FromBody] long[]? ids)
{
if (ids is null || ids.Length == 0) return Ok(new List<Presence2018>());
var online = presence.OnlinePlayerIds().ToHashSet();
var result = ids.Distinct().Select(id => new Presence2018
{
PlayerId = id,
IsOnline = online.Contains(id),
GameSession = null,
}).ToList();
return Ok(result);
}
}