Every failure the server answers with names its own error code
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:
1 parent
f3fdeaf038
commit
c2f439d1e9
25 files changed
+268
-224
No files matched your search
@@ -67,7 +67,7 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
form ??= new ResolveReportForm();
|
||||
var action = string.IsNullOrWhiteSpace(form.Action) ? ModerationActions.None : form.Action.Trim().ToLowerInvariant();
|
||||
if (!ModerationActions.IsResolution(action))
|
||||
return UnprocessableEntity(new WebResult().Invalidate(localizer["Unknown moderation action."], StatusCodes.Status422UnprocessableEntity));
|
||||
return UnprocessableEntity(new WebResult().Invalidate(17001.ToCodedError(localizer["Unknown moderation action."]), StatusCodes.Status422UnprocessableEntity));
|
||||
var by = User.GetUserId();
|
||||
var report = await DB.Default.Find<Report>().MatchID(id).ExecuteFirstAsync(token);
|
||||
if (report == default)
|
||||
@@ -81,7 +81,7 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
break;
|
||||
case ModerationActions.RemovePosts:
|
||||
if (report.PostIds.Count == 0)
|
||||
return UnprocessableEntity(new WebResult().Invalidate(localizer["The report names no posts."], StatusCodes.Status422UnprocessableEntity));
|
||||
return UnprocessableEntity(new WebResult().Invalidate(17002.ToCodedError(localizer["The report names no posts."]), StatusCodes.Status422UnprocessableEntity));
|
||||
foreach (var postId in report.PostIds)
|
||||
{
|
||||
var removed = await accountModeration.RemovePost(by, postId, form.Note, form.Warning, report.ID, token);
|
||||
@@ -172,7 +172,7 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
public async Task<IActionResult> Moderate(ModerateAccountForm form, CancellationToken token)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new WebResult().Invalidate(localizer["Invalid model."]));
|
||||
return BadRequest(new WebResult().Invalidate(17003.ToCodedError(localizer["Invalid model."])));
|
||||
var result = await accountModeration.Moderate(User.GetUserId(), form.AccountId, form.Action.Trim().ToLowerInvariant(), form.Note, form.Warning, default, token);
|
||||
return result.IsValid ? Ok(result.Data) : StatusCode(result.StatusCode, result);
|
||||
}
|
||||
@@ -182,7 +182,7 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
public async Task<IActionResult> RemovePost(RemovePostForm form, CancellationToken token)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new WebResult().Invalidate(localizer["Invalid model."]));
|
||||
return BadRequest(new WebResult().Invalidate(17004.ToCodedError(localizer["Invalid model."])));
|
||||
var result = await accountModeration.RemovePost(User.GetUserId(), form.PostId, form.Note, form.Warning, default, token);
|
||||
return result.IsValid ? Ok() : StatusCode(result.StatusCode, result);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user