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
@@ -64,7 +64,7 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
if (admin == default)
|
||||
return Forbid();
|
||||
if (await MaintenanceLock.Current(token) is { } held)
|
||||
return Conflict(new WebResult().Invalidate(localizer["A {0} is running.", held.What]));
|
||||
return Conflict(new WebResult().Invalidate(11001.ToCodedError(localizer["A {0} is running.", held.What])));
|
||||
await log.Write(admin.ID, Models.AdminActions.BackupCreate, Models.AdminTargets.Backup, default, "manual", token: token);
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
@@ -91,7 +91,7 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
if (admin == default)
|
||||
return Forbid();
|
||||
if (RestoreMarker.Read(backups.Root) is { } waiting && (waiting.Backup == id || waiting.PreRestore == id))
|
||||
return Conflict(new WebResult().Invalidate(localizer["A restore waits for this backup."]));
|
||||
return Conflict(new WebResult().Invalidate(11002.ToCodedError(localizer["A restore waits for this backup."])));
|
||||
if (!backups.Delete(id))
|
||||
return NotFound();
|
||||
await log.Write(admin.ID, Models.AdminActions.BackupDelete, Models.AdminTargets.Backup, id, id, token: token);
|
||||
@@ -106,7 +106,7 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
if (admin == default)
|
||||
return Forbid();
|
||||
if (!PasswordHolds(admin, form.Password))
|
||||
return UnprocessableEntity(new WebResult().Invalidate(localizer["Wrong password."]));
|
||||
return UnprocessableEntity(new WebResult().Invalidate(11003.ToCodedError(localizer["Wrong password."])));
|
||||
if (backups.Find(id) == default)
|
||||
return NotFound();
|
||||
var (ticket, expires) = transfers.Ticket(id);
|
||||
@@ -187,10 +187,10 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
if (await Administrator(token) == default)
|
||||
return Forbid();
|
||||
if (await MaintenanceLock.Current(token) is { What: "restore" })
|
||||
return Conflict(new WebResult().Invalidate(localizer["A {0} is running.", "restore"]));
|
||||
return Conflict(new WebResult().Invalidate(11004.ToCodedError(localizer["A {0} is running.", "restore"])));
|
||||
var (backup, error) = await transfers.Finish(id, token);
|
||||
if (backup == default)
|
||||
return UnprocessableEntity(new WebResult().Invalidate(error));
|
||||
return UnprocessableEntity(new WebResult().Invalidate(11005.ToCodedError(error)));
|
||||
return Ok(View(backup, 0, ServerBackup.CodeMigration()));
|
||||
}
|
||||
|
||||
@@ -210,12 +210,12 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
if (admin == default)
|
||||
return Forbid();
|
||||
if (!PasswordHolds(admin, form.Password))
|
||||
return UnprocessableEntity(new WebResult().Invalidate(localizer["Wrong password."]));
|
||||
return UnprocessableEntity(new WebResult().Invalidate(11006.ToCodedError(localizer["Wrong password."])));
|
||||
if (!string.Equals(form.Host?.Trim(), HostName, StringComparison.OrdinalIgnoreCase))
|
||||
return UnprocessableEntity(new WebResult().Invalidate(localizer["Type this server's host to restore it."]));
|
||||
return UnprocessableEntity(new WebResult().Invalidate(11007.ToCodedError(localizer["Type this server's host to restore it."])));
|
||||
var refused = await ServerRestore.Request(backups.Context(), id, admin.UserName, token);
|
||||
if (refused != default)
|
||||
return UnprocessableEntity(new WebResult().Invalidate(refused));
|
||||
return UnprocessableEntity(new WebResult().Invalidate(11008.ToCodedError(refused)));
|
||||
logger.LogWarning("{Admin} asked to restore {Backup}", admin.UserName, id);
|
||||
await log.Write(admin.ID, Models.AdminActions.BackupRestore, Models.AdminTargets.Backup, id, id, token: token);
|
||||
return Accepted();
|
||||
|
||||
Reference in new issue
Block a user