A posted picture is described again by editing its post
PUT /api/v1/media/:id on a picture already posted changed the upload but never the post, which keeps its own copy, so the new description or focal point reached nobody. As on Mastodon, PUT now takes only media not posted yet (404 otherwise), and a status edit takes media_attributes[] (id, description, focus; from a JSON body or a form): the uploads and the post's copies change, and the Update the edit federates carries them. An edit that sends no media keeps them as they were described. No pasture scenario edits a description, so the sweep could not see this. MediaLifecycleTests: PUT on a posted picture is refused, an edit describes it again and keeps its warning, flag and language as sent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LsXgEaXee4GCU1hwYgPJXw
This commit is contained in:
1 parent
a4ced664cf
commit
5252b8f320
4 files changed
+87
-2
No files matched your search
@@ -74,6 +74,38 @@ namespace PrivaPub.Tests.Http
|
||||
Assert.Equal("edited out", (await DB.Default.Find<MediaAttachment>().OneAsync(dropped, Token)).TrashReason);
|
||||
}
|
||||
|
||||
// a posted picture's description and focus change by editing its post (media_attributes), not by PUT, as on Mastodon
|
||||
[Fact]
|
||||
public async Task An_edit_describes_its_media_again_and_keeps_what_it_is_not_sent()
|
||||
{
|
||||
var alice = await _host.Mastodon("alice");
|
||||
var id = await Upload(alice, "a.jpg");
|
||||
var status = (await alice.Client.Post("/api/v1/statuses", ("status", "described later"), ("media_ids[]", id),
|
||||
("spoiler_text", "a warning"), ("sensitive", "true"), ("language", "it"))).Ok();
|
||||
var statusId = status.Body.Text("id");
|
||||
Assert.Equal(HttpStatusCode.NotFound, (await alice.Client.Put($"/api/v1/media/{id}", ("description", "too late"))).Status);
|
||||
|
||||
var edited = (await alice.Client.Json(HttpMethod.Put, $"/api/v1/statuses/{statusId}", new System.Text.Json.Nodes.JsonObject
|
||||
{
|
||||
["status"] = "described now",
|
||||
["spoiler_text"] = "a warning",
|
||||
["sensitive"] = true,
|
||||
["media_ids"] = new System.Text.Json.Nodes.JsonArray(id),
|
||||
["media_attributes"] = new System.Text.Json.Nodes.JsonArray(new System.Text.Json.Nodes.JsonObject { ["id"] = id, ["description"] = "a red square", ["focus"] = "0.5,0.5" })
|
||||
})).Ok();
|
||||
|
||||
Assert.Equal("a red square", edited.Body["media_attachments"]![0]!.Text("description"));
|
||||
Assert.Equal(0.5, edited.Body["media_attachments"]![0]!["meta"]!["focus"]!["x"]!.GetValue<double>());
|
||||
Assert.Equal("a warning", edited.Body.Text("spoiler_text"));
|
||||
Assert.True(edited.Body["sensitive"]!.GetValue<bool>());
|
||||
Assert.Equal("it", edited.Body.Text("language"));
|
||||
Assert.Equal("a red square", (await DB.Default.Find<MediaAttachment>().OneAsync(id, Token)).Description);
|
||||
|
||||
// an edit that doesn't send media keeps them, described as they were
|
||||
var kept = (await alice.Client.Put($"/api/v1/statuses/{statusId}", ("status", "media kept"))).Ok();
|
||||
Assert.Equal("a red square", kept.Body["media_attachments"]![0]!.Text("description"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task A_replaced_avatar_is_trashed_and_a_picture_that_is_not_one_is_refused()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user