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
@@ -17,12 +17,12 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
// ten minutes; another archive (its own, or Mastodon's) uploaded in pieces and imported into it in a job, the parts the
|
||||
// root picks, with progress, until it asks to stop. Only the persona's own root, never a banned one.
|
||||
[ApiController,
|
||||
Route("clientapi/persona"),
|
||||
Route(ApiPaths.PersonaArchive.Prefix),
|
||||
Authorize(Policy = Policies.IsUser)]
|
||||
public class PersonaArchiveController(Backups backups, TransferStore transfers, IJobQueue jobs, Federation.Actors.ILocalActorService localActors)
|
||||
: ControllerBase
|
||||
{
|
||||
[HttpGet, Route("{avatarId}/archive")]
|
||||
[HttpGet, Route(ApiPaths.PersonaArchive.GET_M_Status)]
|
||||
public async Task<IActionResult> Status(string avatarId, CancellationToken token)
|
||||
{
|
||||
if (!await Owns(avatarId, token))
|
||||
@@ -31,7 +31,7 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
return Ok(PersonaArchives.View(await PersonaArchives.Of(avatarId, token)));
|
||||
}
|
||||
|
||||
[HttpPost, Route("{avatarId}/archive")]
|
||||
[HttpPost, Route(ApiPaths.PersonaArchive.POST_M_Export)]
|
||||
public async Task<IActionResult> Export(string avatarId, CancellationToken token)
|
||||
{
|
||||
if (!await Owns(avatarId, token))
|
||||
@@ -47,7 +47,7 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
return Accepted(PersonaArchives.View(state));
|
||||
}
|
||||
|
||||
[HttpPost, Route("{avatarId}/archive/ticket")]
|
||||
[HttpPost, Route(ApiPaths.PersonaArchive.POST_M_Ticket)]
|
||||
public async Task<IActionResult> Ticket(string avatarId, CancellationToken token)
|
||||
{
|
||||
if (!await Owns(avatarId, token))
|
||||
@@ -61,7 +61,7 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
}
|
||||
|
||||
// the archive itself, for a ticket: a plain link, so the browser saves it to disk (and resumes it)
|
||||
[HttpGet, Route("archive/download/{ticket}"), AllowAnonymous]
|
||||
[HttpGet, Route(ApiPaths.PersonaArchive.GET_M_Download), AllowAnonymous]
|
||||
public IActionResult Download(string ticket)
|
||||
{
|
||||
if (transfers.Redeem(ticket) is not { } what || what.Split('/') is not ["persona", var avatarId, var name] || name.Contains(".."))
|
||||
@@ -73,11 +73,11 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
return PhysicalFile(file, "application/zip", name, enableRangeProcessing: true);
|
||||
}
|
||||
|
||||
[HttpPost, Route("archive/uploads")]
|
||||
[HttpPost, Route(ApiPaths.PersonaArchive.POST_StartUpload)]
|
||||
public IActionResult StartUpload() =>
|
||||
Ok(new ViewArchiveUpload { Id = transfers.Start(User.GetUserId()), ChunkBytes = TransferStore.ChunkBytes });
|
||||
|
||||
[HttpGet, Route("archive/uploads/{id}")]
|
||||
[HttpGet, Route(ApiPaths.PersonaArchive.GET_M_Upload)]
|
||||
public IActionResult Upload(string id)
|
||||
{
|
||||
if (transfers.Owner(id) != User.GetUserId())
|
||||
@@ -85,7 +85,7 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
return Ok(new ViewArchiveUpload { Id = id, Received = transfers.Received(id), ChunkBytes = TransferStore.ChunkBytes });
|
||||
}
|
||||
|
||||
[HttpPut, Route("archive/uploads/{id}"), RequestSizeLimit(TransferStore.ChunkBytes + 1024 * 1024)]
|
||||
[HttpPut, Route(ApiPaths.PersonaArchive.PUT_M_Append), RequestSizeLimit(TransferStore.ChunkBytes + 1024 * 1024)]
|
||||
public async Task<IActionResult> Append(string id, [FromQuery] long offset, CancellationToken token)
|
||||
{
|
||||
if (transfers.Owner(id) != User.GetUserId())
|
||||
@@ -95,7 +95,7 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
return taken ? Ok(view) : Conflict(view);
|
||||
}
|
||||
|
||||
[HttpDelete, Route("archive/uploads/{id}")]
|
||||
[HttpDelete, Route(ApiPaths.PersonaArchive.DELETE_M_CancelUpload)]
|
||||
public IActionResult CancelUpload(string id)
|
||||
{
|
||||
if (transfers.Owner(id) != User.GetUserId())
|
||||
@@ -105,7 +105,7 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
}
|
||||
|
||||
// an uploaded archive imported into the persona: refused at once when it is not one, or holds what it must not
|
||||
[HttpPost, Route("{avatarId}/archive/import")]
|
||||
[HttpPost, Route(ApiPaths.PersonaArchive.POST_M_Import)]
|
||||
public async Task<IActionResult> Import(string avatarId, ImportPersonaArchiveForm form, CancellationToken token)
|
||||
{
|
||||
if (!await Owns(avatarId, token))
|
||||
@@ -142,7 +142,7 @@ namespace PrivaPub.Controllers.ClientToServer
|
||||
return Accepted(PersonaArchives.View(state));
|
||||
}
|
||||
|
||||
[HttpPost, Route("{avatarId}/archive/import/stop")]
|
||||
[HttpPost, Route(ApiPaths.PersonaArchive.POST_M_Stop)]
|
||||
public async Task<IActionResult> Stop(string avatarId, CancellationToken token)
|
||||
{
|
||||
if (!await Owns(avatarId, token))
|
||||
|
||||
Reference in new issue
Block a user