Every failure the server answers with names its own error code
Build / Build (push) Successful in 34s
Deploy / privapub.thepra.dev (push) Successful in 57s
Deploy / Release notes on the Releases tab (push) Successful in 3s

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
This commit is contained in:
thepraandClaude Opus 5.5 committed 2026-11-10 08:11:24 +01:00
1 parent f3fdeaf038
commit c2f439d1e9
25 files changed
+268 -224

No files matched your search

@@ -30,7 +30,7 @@ namespace PrivaPub.Controllers.ClientToServer
{
var result = new WebResult();
if (!ModelState.IsValid)
return BadRequest(result.Invalidate(localizer["Invalid model."]));
return BadRequest(result.Invalidate(20001.ToCodedError(localizer["Invalid model."])));
try
{
model.RootId = User.GetUserId();
@@ -43,7 +43,7 @@ namespace PrivaPub.Controllers.ClientToServer
catch (Exception ex)
{
logger.LogError(ex, $"{nameof(PrivateAvatarController)}.{nameof(InsertAvatar)}()");
return BadRequest(result.Invalidate(localizer["Something went wrong."]));
return BadRequest(result.Invalidate(20002.ToCodedError(localizer["Something went wrong."])));
}
}
@@ -54,13 +54,13 @@ namespace PrivaPub.Controllers.ClientToServer
[FromServices] Services.IPersonaRemoval personas, [FromServices] StaticServices.DbEntities dbEntities, CancellationToken token)
{
if (!ModelState.IsValid)
return BadRequest(new WebResult().Invalidate(localizer["Invalid model."]));
return BadRequest(new WebResult().Invalidate(20003.ToCodedError(localizer["Invalid model."])));
var rootId = User.GetUserId();
if (!await users.PasswordMatches(rootId, form.Password, token))
return StatusCode(StatusCodes.Status403Forbidden, new WebResult().Invalidate(localizer[Services.RootUsersService.NoMatch], StatusCodes.Status403Forbidden));
return StatusCode(StatusCodes.Status403Forbidden, new WebResult().Invalidate(20004.ToCodedError(localizer[Services.RootUsersService.NoMatch]), StatusCodes.Status403Forbidden));
if (!await dbEntities.RootToAvatars.Match(ra => ra.RootId == rootId && ra.AvatarId == form.AvatarId).ExecuteAnyAsync(token)
|| !await personas.Remove(form.AvatarId, CancellationToken.None))
return NotFound(new WebResult().Invalidate(localizer["Avatar not found."], StatusCodes.Status404NotFound));
return NotFound(new WebResult().Invalidate(20005.ToCodedError(localizer["Avatar not found."]), StatusCodes.Status404NotFound));
return Ok();
}
@@ -70,7 +70,7 @@ namespace PrivaPub.Controllers.ClientToServer
{
var avatar = await OwnPersona(avatarId, dbEntities, token);
return avatar == default
? NotFound(new WebResult().Invalidate(localizer["Avatar not found."], StatusCodes.Status404NotFound))
? NotFound(new WebResult().Invalidate(20006.ToCodedError(localizer["Avatar not found."]), StatusCodes.Status404NotFound))
: Ok(PreferencesOf(avatar));
}
@@ -78,12 +78,12 @@ namespace PrivaPub.Controllers.ClientToServer
public async Task<IActionResult> SavePreferences(PersonaPreferencesForm form, [FromServices] StaticServices.DbEntities dbEntities, CancellationToken token)
{
if (!ModelState.IsValid)
return BadRequest(new WebResult().Invalidate(localizer["Invalid model."]));
return BadRequest(new WebResult().Invalidate(20007.ToCodedError(localizer["Invalid model."])));
if (!Models.User.ExpandMediaModes.IsKnown(form.ExpandMedia))
return UnprocessableEntity(new WebResult().Invalidate(localizer["Media are shown as default, show_all or hide_all."], StatusCodes.Status422UnprocessableEntity));
return UnprocessableEntity(new WebResult().Invalidate(20008.ToCodedError(localizer["Media are shown as default, show_all or hide_all."]), StatusCodes.Status422UnprocessableEntity));
var avatar = await OwnPersona(form.AvatarId, dbEntities, token);
if (avatar == default)
return NotFound(new WebResult().Invalidate(localizer["Avatar not found."], StatusCodes.Status404NotFound));
return NotFound(new WebResult().Invalidate(20009.ToCodedError(localizer["Avatar not found."]), StatusCodes.Status404NotFound));
await MongoDB.Entities.DB.Default.Update<Models.User.Avatar>().MatchID(avatar.ID)
.Modify(a => a.Settings.ExpandMedia, form.ExpandMedia)
.Modify(a => a.Settings.ExpandSpoilers, form.ExpandSpoilers)
@@ -114,7 +114,7 @@ namespace PrivaPub.Controllers.ClientToServer
{
var result = new WebResult();
if (!ModelState.IsValid)
return BadRequest(result.Invalidate(localizer["Invalid model."]));
return BadRequest(result.Invalidate(20010.ToCodedError(localizer["Invalid model."])));
try
{
model.RootId = User.GetUserId();
@@ -127,7 +127,7 @@ namespace PrivaPub.Controllers.ClientToServer
catch (Exception ex)
{
logger.LogError(ex, $"{nameof(PrivateAvatarController)}.{nameof(UpdateAvatar)}()");
return BadRequest(result.Invalidate(localizer["Something went wrong."]));
return BadRequest(result.Invalidate(20011.ToCodedError(localizer["Something went wrong."])));
}
}