All 384 routes, the Mastodon API, the client API and the frozen federation paths, are read from one class with one nested class per controller. Their values are unchanged, checked one by one against the old literals; decePubClient keeps its own APIs class. Checked against GoToSocial in the pasture: 64 passed, 0 failed. 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
0f73f69239
commit
739a1603ca
47 files changed
+952
-373
No files matched your search
@@ -22,12 +22,12 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
// restore for the server's host typed out. A restore asked for stops the service within seconds, and the next start
|
||||
// carries it out (ServerRestore).
|
||||
[ApiController,
|
||||
Route("clientapi/admin/backups"),
|
||||
Route(ApiPaths.Backup.Prefix),
|
||||
Authorize(Policy = Policies.IsAdmin)]
|
||||
public class BackupController(Backups backups, TransferStore transfers, IPasswordHasher hasher, IStringLocalizer<GenericRes> localizer,
|
||||
ILogger<BackupController> logger, IModerationLog log) : ControllerBase
|
||||
{
|
||||
[HttpGet, Route("")]
|
||||
[HttpGet, Route(ApiPaths.Backup.GET_List)]
|
||||
public async Task<IActionResult> List(CancellationToken token)
|
||||
{
|
||||
if (await Administrator(token) == default)
|
||||
@@ -57,7 +57,7 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
}
|
||||
|
||||
// a backup made now, while the page polls the list
|
||||
[HttpPost, Route("")]
|
||||
[HttpPost, Route(ApiPaths.Backup.POST_Create)]
|
||||
public async Task<IActionResult> Create(CancellationToken token)
|
||||
{
|
||||
var admin = await Administrator(token);
|
||||
@@ -84,7 +84,7 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
return Accepted();
|
||||
}
|
||||
|
||||
[HttpDelete, Route("{id}")]
|
||||
[HttpDelete, Route(ApiPaths.Backup.DELETE_M_Delete)]
|
||||
public async Task<IActionResult> Delete(string id, CancellationToken token)
|
||||
{
|
||||
var admin = await Administrator(token);
|
||||
@@ -99,7 +99,7 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
}
|
||||
|
||||
// a link to download it with, for the password
|
||||
[HttpPost, Route("{id}/ticket")]
|
||||
[HttpPost, Route(ApiPaths.Backup.POST_M_Ticket)]
|
||||
public async Task<IActionResult> Ticket(string id, BackupPasswordForm form, CancellationToken token)
|
||||
{
|
||||
var admin = await Administrator(token);
|
||||
@@ -114,7 +114,7 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
}
|
||||
|
||||
// the backup as one tar, for a ticket: a plain link, so the browser downloads it to disk and resumes it
|
||||
[HttpGet, Route("download/{ticket}"), AllowAnonymous]
|
||||
[HttpGet, Route(ApiPaths.Backup.GET_M_Download), AllowAnonymous]
|
||||
public async Task Download(string ticket, CancellationToken token)
|
||||
{
|
||||
var id = transfers.Redeem(ticket);
|
||||
@@ -150,7 +150,7 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
await tar.Write(Response.Body, from, to, token);
|
||||
}
|
||||
|
||||
[HttpPost, Route("uploads")]
|
||||
[HttpPost, Route(ApiPaths.Backup.POST_StartUpload)]
|
||||
public async Task<IActionResult> StartUpload(CancellationToken token)
|
||||
{
|
||||
var admin = await Administrator(token);
|
||||
@@ -159,7 +159,7 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
return Ok(new ViewBackupUpload { Id = transfers.Start(admin.UserName), ChunkBytes = TransferStore.ChunkBytes });
|
||||
}
|
||||
|
||||
[HttpGet, Route("uploads/{id}")]
|
||||
[HttpGet, Route(ApiPaths.Backup.GET_M_Upload)]
|
||||
public async Task<IActionResult> Upload(string id, CancellationToken token)
|
||||
{
|
||||
if (await Administrator(token) == default)
|
||||
@@ -169,7 +169,7 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
}
|
||||
|
||||
// a piece, at the offset already received: 409 with what was received when it isn't
|
||||
[HttpPut, Route("uploads/{id}"), RequestSizeLimit(TransferStore.ChunkBytes + 1024 * 1024)]
|
||||
[HttpPut, Route(ApiPaths.Backup.PUT_M_Append), RequestSizeLimit(TransferStore.ChunkBytes + 1024 * 1024)]
|
||||
public async Task<IActionResult> Append(string id, [FromQuery] long offset, CancellationToken token)
|
||||
{
|
||||
if (await Administrator(token) == default)
|
||||
@@ -181,7 +181,7 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
return taken ? Ok(view) : Conflict(view);
|
||||
}
|
||||
|
||||
[HttpPost, Route("uploads/{id}/finish")]
|
||||
[HttpPost, Route(ApiPaths.Backup.POST_M_FinishUpload)]
|
||||
public async Task<IActionResult> FinishUpload(string id, CancellationToken token)
|
||||
{
|
||||
if (await Administrator(token) == default)
|
||||
@@ -194,7 +194,7 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
return Ok(View(backup, 0, ServerBackup.CodeMigration()));
|
||||
}
|
||||
|
||||
[HttpDelete, Route("uploads/{id}")]
|
||||
[HttpDelete, Route(ApiPaths.Backup.DELETE_M_CancelUpload)]
|
||||
public async Task<IActionResult> CancelUpload(string id, CancellationToken token)
|
||||
{
|
||||
if (await Administrator(token) == default)
|
||||
@@ -203,7 +203,7 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
}
|
||||
|
||||
// asked for with the password and the host typed out: the service stops within seconds and restores it as it starts
|
||||
[HttpPost, Route("{id}/restore")]
|
||||
[HttpPost, Route(ApiPaths.Backup.POST_M_Restore)]
|
||||
public async Task<IActionResult> Restore(string id, RestoreBackupForm form, CancellationToken token)
|
||||
{
|
||||
var admin = await Administrator(token);
|
||||
|
||||
Reference in new issue
Block a user