Files
SocialPub/PrivaPub/Controllers/ClientToServer/DataController.cs
T
thepraandClaude Opus 5.5 0f85030744 No admin by username, no Swagger in production, no exception text to clients
S14 and the privacy items of P0:
- signing up as "admin" no longer grants admin; `PrivaPub admin promote
  <root>` (and `demote`) does, run on the box against the configured
  database;
- Swagger is served in Development only;
- every service and controller answers "Something went wrong." where it
  used to send ex.Message, and the SMTP warnings no longer log the
  recipient's address;
- sign-up and login no longer log the IP, User-Agent and root id together;
- invitation sign-up takes the persona's own AvatarUserName (and optional
  AvatarName) instead of naming the avatar after the private login, and
  refuses a persona username equal to the login's. Invitation login uses
  the named persona, creating it if it is new;
- recovery mail comes from "PrivaPub", not collAnon's support address name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012CzABvBkbcFqoHdmi8b9WB
2026-10-01 10:58:39 +02:00

55 lines
1.5 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("clientapi/data")]
public class DataController : ControllerBase
{
readonly IDataService DataService;
readonly ILogger<DataController> Logger;
public DataController(IDataService dataService,
ILogger<DataController> logger)
{
DataService = dataService;
Logger = logger;
}
[HttpGet, Route("/clientapi/data/ping"), AllowAnonymous]
public async ValueTask<IActionResult> Ping() => NoContent();
[HttpGet, Route("/clientapi/data/current-version"), AllowAnonymous]
public IActionResult CurrentVersion() =>
Ok(DataService.GetCurrentVersion());
[HttpGet, Route("/clientapi/data/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));
}
}
}
}