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
@@ -69,7 +69,7 @@ namespace PrivaPub.Domain.Moderation
|
||||
{
|
||||
var result = new WebResult();
|
||||
if (!ModerationActions.IsAccountAction(action))
|
||||
return result.Invalidate(localizer["Unknown moderation action."], StatusCodes.Status422UnprocessableEntity);
|
||||
return result.Invalidate(23001.ToCodedError(localizer["Unknown moderation action."]), StatusCodes.Status422UnprocessableEntity);
|
||||
try
|
||||
{
|
||||
var avatar = string.IsNullOrEmpty(accountId) ? default : await dbEntities.Avatars.MatchID(accountId).Match(a => !a.DeletionAt.HasValue).ExecuteFirstAsync(token);
|
||||
@@ -80,14 +80,14 @@ namespace PrivaPub.Domain.Moderation
|
||||
}
|
||||
var account = string.IsNullOrEmpty(accountId) ? default : await dbEntities.ForeignAvatars.MatchID(accountId).ExecuteFirstAsync(token);
|
||||
if (account == default)
|
||||
return result.Invalidate(localizer["Account not found."], StatusCodes.Status404NotFound);
|
||||
return result.Invalidate(23002.ToCodedError(localizer["Account not found."]), StatusCodes.Status404NotFound);
|
||||
result.Data = await Remote(byRootId, account, action, note, reportId, token);
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "{Service}.{Method}({Action})", nameof(AccountModeration), nameof(Moderate), action);
|
||||
return result.Invalidate(localizer["Something went wrong."], exception: ex);
|
||||
return result.Invalidate(23003.ToCodedError(localizer["Something went wrong."]), exception: ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,18 +213,18 @@ namespace PrivaPub.Domain.Moderation
|
||||
{
|
||||
var post = string.IsNullOrEmpty(postId) ? default : await dbEntities.Posts.MatchID(postId).ExecuteFirstAsync(token);
|
||||
if (post == default || post.DeletedAt.HasValue || post.ModeratedAt.HasValue)
|
||||
return result.Invalidate(localizer["Post not found."], StatusCodes.Status404NotFound);
|
||||
return result.Invalidate(23004.ToCodedError(localizer["Post not found."]), StatusCodes.Status404NotFound);
|
||||
|
||||
if (!post.IsFederatedCopy)
|
||||
{
|
||||
var author = await localActors.FindById(LocalActorKind.Person, post.GroupUserId, token);
|
||||
if (author == default)
|
||||
return result.Invalidate(localizer["Post not found."], StatusCodes.Status404NotFound);
|
||||
return result.Invalidate(23005.ToCodedError(localizer["Post not found."]), StatusCodes.Status404NotFound);
|
||||
// deleted as its author deletes it: emptied, out of every timeline, and a Delete to its audience (but from a
|
||||
// suspended persona, which delivers nothing)
|
||||
var outcome = await statuses.Remove(author, post.ID, CancellationToken.None);
|
||||
if (!outcome.Ok)
|
||||
return result.Invalidate(localizer["Post not found."], outcome.Status);
|
||||
return result.Invalidate(23006.ToCodedError(localizer["Post not found."]), outcome.Status);
|
||||
await Social.Notifications.Warn(author.Id, author.Uri, "delete_statuses", warning, new[] { post.ID }, token);
|
||||
await log.Write(byRootId, AdminActions.PostRemove, AdminTargets.Post, post.ID, $"@{author.Handle}: {post.ObjectURI}", reportId, note,
|
||||
CancellationToken.None);
|
||||
@@ -240,7 +240,7 @@ namespace PrivaPub.Domain.Moderation
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "{Service}.{Method}()", nameof(AccountModeration), nameof(RemovePost));
|
||||
return result.Invalidate(localizer["Something went wrong."], exception: ex);
|
||||
return result.Invalidate(23007.ToCodedError(localizer["Something went wrong."]), exception: ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user