Each refusal and failure the client API sends now starts with a code no other failure uses, such as "[ERR0030006] That code is not valid.", so a screenshot or a report points at the exact place it came from. Nothing another program reads changes: ActivityPub, the Mastodon API's errors, sign-in tokens and the error kinds decePubClient branches on stay as they were. The house-rules checks move to 1.1.0. 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(12001.ToCodedError("Something went wrong."), exception: ex));
|
|
}
|
|
}
|
|
}
|
|
} |