Build / Build (push) Successful in 1m7s
Starts the completion program (docs/ROADMAP.md, "Owner decisions on finishing everything", 2026-10-17). - Dead code: the commented-out collAnon blocks (discussions, seeding, admin user lists, HTTP/3, the old signature middleware), the empty PrivaPubWorkersConfiguration, PublicAvatarUsersService and UserPolicyType, unused helpers, the second IPasswordHasher registration, the PasswordGenerator package, SignUpAsync/LoginAsync's unused invitation parameters. "Starting PrivaPub"; a signed-in login is sent to "/", not to "/discussions". - Stored fields nothing read: RootUser.Contacts and ResetPasswordToken*, the local Avatar.AvatarServer, EmailRecovery.RecoveryCode/RequestIP/CreationDate, MongoSettings.LogsDatabase, and AppConfiguration's upload/discussion keys, RequiresFirstTimeSetup and Version (old documents still load: MongoDB.Entities ignores extra elements). DmPost's indexes are no longer made. 49 collAnon keys leave FieldsNameResource in every language. - /clientapi/data/current-version answers the build's ref. UsersIds is a list that can't throw, and the admin routes leave the administrator out without mutating the request. - deploy.yml checks SecureMode on a name no persona can have, and the browser redirect on the directory's first local persona: @thepra is the administrator's own now. - Town: decePub's e2e remnants (expect, client.jsonl, the decePub column) and town/tests go; the dead gaps/load commands too. Mobilizon no longer keeps an event for a deleted test. - tools/pasture/sweep.sh runs every peer's scenario, batch by batch, as CLAUDE.md asks before a change to what PrivaPub sends. - Docs: CLAUDE.md's repo map, route table (every frozen route) and stale lines; ROADMAP's status (setup, v1.25.0, v1.26.0, the program C), the 2026-10-17 decisions, and dated notes where earlier text no longer holds; FEDERATION.md's FEP list (7888, f228, 7628, ae0c and 8967 supported) and the deploy's persona. Verified: dotnet build PrivaPub.sln -c Release (0 errors, no new warnings); bash -n on the touched scripts; py_compile on the town; the pasture's gts, mastodon and lemmy scenarios on this build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WpVCoDeM1qUTRp4fXQdfof
102 lines
2.9 KiB
C#
102 lines
2.9 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Extensions.Localization;
|
|
|
|
using PrivaPub.ClientModels;
|
|
using PrivaPub.ClientModels.User;
|
|
using PrivaPub.Extensions;
|
|
using PrivaPub.Resources;
|
|
using PrivaPub.Services;
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
namespace PrivaPub.Controllers.ClientToServer
|
|
{
|
|
[ApiController,
|
|
Route("clientapi/admin")]
|
|
public class AdminController : ControllerBase
|
|
{
|
|
readonly IRootUsersService RootUsersService;
|
|
readonly ILogger<RootUserController> Logger;
|
|
readonly IStringLocalizer Localizer;
|
|
|
|
public AdminController(ILogger<RootUserController> logger,
|
|
IStringLocalizer<GenericRes> localizer,
|
|
IRootUsersService rootUsersService)
|
|
{
|
|
Logger = logger;
|
|
Localizer = localizer;
|
|
RootUsersService = rootUsersService;
|
|
}
|
|
|
|
// an administrator never removes, bans or unbans itself; the request's own list is left as it came
|
|
UsersIds Others(UsersIds usersIds)
|
|
{
|
|
var selfId = User.GetUserId();
|
|
return new UsersIds { UserIdList = usersIds.UserIdList.Where(id => id != selfId).ToList() };
|
|
}
|
|
|
|
[HttpDelete, Route("/clientapi/admin/remove/users"), Authorize(Policy = Policies.IsAdmin)]
|
|
public async Task<IActionResult> RemoveUsers([Required] UsersIds usersIds)
|
|
{
|
|
var result = new WebResult();
|
|
try
|
|
{
|
|
result = await RootUsersService.RemoveUserAsync(Others(usersIds));
|
|
if (!result.IsValid)
|
|
return StatusCode(result.StatusCode, result);
|
|
|
|
return Ok();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Logger.LogError(ex, $"{nameof(User)}.{nameof(RemoveUsers)}()");
|
|
return BadRequest(result.Invalidate(Localizer["Something went wrong."]));
|
|
}
|
|
}
|
|
|
|
[HttpPost, Authorize(Policy = Policies.IsAdmin), Route("/clientapi/admin/ban/users")]
|
|
public async Task<IActionResult> BanUsers([Required] UsersIds usersIds)
|
|
{
|
|
if (!ModelState.IsValid)
|
|
return BadRequest(usersIds);
|
|
var result = new WebResult();
|
|
try
|
|
{
|
|
result = await RootUsersService.BanUserAsync(Others(usersIds));
|
|
|
|
if (!result.IsValid)
|
|
return StatusCode(result.StatusCode, result);
|
|
|
|
return Ok();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Logger.LogError(ex, $"{nameof(User)}.{nameof(BanUsers)}()");
|
|
return BadRequest(result.Invalidate(Localizer["Something went wrong."]));
|
|
}
|
|
}
|
|
|
|
[HttpPost, Authorize(Policy = Policies.IsAdmin), Route("/clientapi/admin/unban/users")]
|
|
public async Task<IActionResult> UnbanUsers([Required] UsersIds usersIds)
|
|
{
|
|
if (!ModelState.IsValid)
|
|
return BadRequest(usersIds);
|
|
var result = new WebResult();
|
|
try
|
|
{
|
|
result = await RootUsersService.UnbanUserAsync(Others(usersIds));
|
|
if (!result.IsValid)
|
|
return StatusCode(result.StatusCode, result);
|
|
|
|
return Ok();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Logger.LogError(ex, $"{nameof(User)}.{nameof(UnbanUsers)}()");
|
|
return BadRequest(result.Invalidate(Localizer["Something went wrong."]));
|
|
}
|
|
}
|
|
}
|
|
}
|