Build / Build (push) Successful in 35s
All 384 routes, the Mastodon API, the client API and the frozen federation paths, are read from one class with one nested class per controller. Their values are unchanged, checked one by one against the old literals; decePubClient keeps its own APIs class. Checked against GoToSocial in the pasture: 64 passed, 0 failed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W4YtEJrgxG12Pc39Fai8Bd
47 lines
1.4 KiB
C#
47 lines
1.4 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using PrivaPub.ClientModels;
|
|
using PrivaPub.ClientModels.Data;
|
|
using PrivaPub.Services.ClientToServer.Public;
|
|
|
|
namespace PrivaPub.Controllers.ClientToServer
|
|
{
|
|
[ApiController,
|
|
Route(ApiPaths.Data.Prefix)]
|
|
public class DataController(
|
|
IDataService dataService,
|
|
ILogger<DataController> logger) : ControllerBase
|
|
{
|
|
[HttpGet, Route(ApiPaths.Data.GET_Ping), AllowAnonymous]
|
|
public async ValueTask<IActionResult> Ping(CancellationToken token = default) => NoContent();
|
|
|
|
[HttpGet, Route(ApiPaths.Data.GET_CurrentVersion), AllowAnonymous]
|
|
public IActionResult CurrentVersion() =>
|
|
Ok(dataService.GetCurrentVersion());
|
|
|
|
[HttpGet, Route(ApiPaths.Data.GET_Languages), AllowAnonymous]
|
|
public async Task<IActionResult> Languages(CancellationToken cancellationToken)
|
|
{
|
|
var result = new WebResult();
|
|
try
|
|
{
|
|
var languages = await dataService.GetLanguages(cancellationToken);
|
|
var viewLanguages = new List<ViewLanguage>();
|
|
|
|
viewLanguages.AddRange(languages.Select(l => new ViewLanguage
|
|
{
|
|
Name = l.NativeName,
|
|
International2Code = l.International2Code
|
|
}).ToArray());
|
|
|
|
return Ok(viewLanguages);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
logger.LogError(ex, $"{nameof(DataController)}.{nameof(Languages)}()");
|
|
return BadRequest(result.Invalidate("Something went wrong.", exception: ex));
|
|
}
|
|
}
|
|
}
|
|
} |