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

@@ -43,7 +43,7 @@ namespace PrivaPub.Controllers.ClientToServer
return root is { IsBanned: false, DeletedAt: null } && root.Policies.Contains(Policies.IsAdmin) ? root : default;
}
IActionResult Refused(int status, string message) => StatusCode(status, new WebResult().Invalidate(localizer[message], status));
IActionResult Refused(int status, string message, int errorCode) => StatusCode(status, new WebResult().Invalidate(errorCode.ToCodedError(localizer[message]), status));
[HttpGet, Route(ApiPaths.EmojiAdmin.GET_List)]
public async Task<IActionResult> List(CancellationToken token)
@@ -64,10 +64,10 @@ namespace PrivaPub.Controllers.ClientToServer
var key = form.Shortcode.ToLowerInvariant();
var existing = await DB.Default.Find<LocalEmoji>().Match(e => e.Key == key).ExecuteFirstAsync(token);
if (existing != default && (existing.DeletedAt == default || existing.Shortcode != form.Shortcode))
return Refused(StatusCodes.Status409Conflict, "This shortcode is taken.");
return Refused(StatusCodes.Status409Conflict, "This shortcode is taken.", 14004);
var outcome = await media.EmojiImage(form.Shortcode, await Picture(token), token);
if (!outcome.Ok)
return StatusCode(outcome.Status, new WebResult().Invalidate(outcome.Error, outcome.Status));
return StatusCode(outcome.Status, new WebResult().Invalidate(14002.ToCodedError(outcome.Error), outcome.Status));
var now = DateTime.UtcNow;
var emoji = existing ?? new LocalEmoji { Shortcode = form.Shortcode, Key = key, CreatedAt = now };
@@ -93,7 +93,7 @@ namespace PrivaPub.Controllers.ClientToServer
if (!saved)
{
await media.Trash(m => m.ID == outcome.Attachment.ID, "emoji not saved", token);
return Refused(StatusCodes.Status409Conflict, "This shortcode is taken.");
return Refused(StatusCodes.Status409Conflict, "This shortcode is taken.", 14005);
}
await LocalEmojis.Reload(CancellationToken.None);
var notes = new[] { existing != default ? "added again" : default, emoji.Disabled ? "disabled" : default, Animated(emoji) }.Where(n => n != default).ToList();
@@ -133,7 +133,7 @@ namespace PrivaPub.Controllers.ClientToServer
{
outcome = await media.EmojiImage(emoji.Shortcode, image, token);
if (!outcome.Ok)
return StatusCode(outcome.Status, new WebResult().Invalidate(outcome.Error, outcome.Status));
return StatusCode(outcome.Status, new WebResult().Invalidate(14003.ToCodedError(outcome.Error), outcome.Status));
Picture(emoji, outcome.Attachment, now);
changed.Add("image");
}