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

@@ -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);
}
}
+6 -6
View File
@@ -53,17 +53,17 @@ namespace PrivaPub.Domain.Social
{
var follower = await OwnedAvatar(rootUserId, form.AvatarId, token);
if (follower == default)
return result.Invalidate(localizer["Avatar not found."], StatusCodes.Status404NotFound);
return result.Invalidate(24001.ToCodedError(localizer["Avatar not found."]), StatusCodes.Status404NotFound);
var following = await FollowAs(follower, form.Target, true, token: token);
if (following == default)
return result.Invalidate(localizer["Account not found."], StatusCodes.Status404NotFound);
return result.Invalidate(24002.ToCodedError(localizer["Account not found."]), StatusCodes.Status404NotFound);
result.Data = ToView(following);
return result;
}
catch (Exception ex)
{
logger.LogError(ex, $"{nameof(FollowService)}.{nameof(Follow)}");
return result.Invalidate(localizer["Something went wrong."], exception: ex);
return result.Invalidate(24003.ToCodedError(localizer["Something went wrong."]), exception: ex);
}
}
@@ -74,14 +74,14 @@ namespace PrivaPub.Domain.Social
{
var follower = await OwnedAvatar(rootUserId, form.AvatarId, token);
if (follower == default)
return result.Invalidate(localizer["Avatar not found."], StatusCodes.Status404NotFound);
return result.Invalidate(24004.ToCodedError(localizer["Avatar not found."]), StatusCodes.Status404NotFound);
await UnfollowAs(follower, form.Target, token);
return result;
}
catch (Exception ex)
{
logger.LogError(ex, $"{nameof(FollowService)}.{nameof(Unfollow)}");
return result.Invalidate(localizer["Something went wrong."], exception: ex);
return result.Invalidate(24005.ToCodedError(localizer["Something went wrong."]), exception: ex);
}
}
@@ -251,7 +251,7 @@ namespace PrivaPub.Domain.Social
var result = new WebResult();
var follower = await OwnedAvatar(rootUserId, avatarId, token);
if (follower == default)
return result.Invalidate(localizer["Avatar not found."], StatusCodes.Status404NotFound);
return result.Invalidate(24006.ToCodedError(localizer["Avatar not found."]), StatusCodes.Status404NotFound);
result.Data = (await dbEntities.Followings.Match(f => f.AvatarId == follower.Id).Sort(f => f.ID, Order.Descending).ExecuteAsync(token))
.Select(ToView).ToList();
return result;
+3 -3
View File
@@ -31,7 +31,7 @@ namespace PrivaPub.Domain.Timelines
{
var result = new WebResult();
if (!await Owns(rootUserId, avatarId, token))
return result.Invalidate(localizer["Avatar not found."], StatusCodes.Status404NotFound);
return result.Invalidate(25001.ToCodedError(localizer["Avatar not found."]), StatusCodes.Status404NotFound);
var query = dbEntities.TimelineEntries.Match(e => e.AvatarId == avatarId);
if (!string.IsNullOrEmpty(maxId))
@@ -60,7 +60,7 @@ namespace PrivaPub.Domain.Timelines
{
var result = new WebResult();
if (!await Owns(rootUserId, avatarId, token))
return result.Invalidate(localizer["Avatar not found."], StatusCodes.Status404NotFound);
return result.Invalidate(25002.ToCodedError(localizer["Avatar not found."]), StatusCodes.Status404NotFound);
var query = dbEntities.Notifications.Match(n => n.AvatarId == avatarId);
if (!string.IsNullOrEmpty(maxId))
@@ -84,7 +84,7 @@ namespace PrivaPub.Domain.Timelines
{
var result = new WebResult();
if (!await Owns(rootUserId, avatarId, token))
return result.Invalidate(localizer["Avatar not found."], StatusCodes.Status404NotFound);
return result.Invalidate(25003.ToCodedError(localizer["Avatar not found."]), StatusCodes.Status404NotFound);
await DB.Default.Update<Notification>().Match(n => n.AvatarId == avatarId && !n.IsRead).Modify(n => n.IsRead, true).ExecuteAsync(token);
return result;
}