A post named by its page is found as by its id
Pixelfed names one of our posts by the address of its page (/@name/<post id>, the post's url) in its Like, Announce and their Undo, so its likes were dropped as unknown objects. Before an activity is handled, such a reference to a post of ours, as its object or the object of the activity it undoes, is replaced by the post's id. Found by the pasture's new Pixelfed peer. 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
34c0f696af
commit
26dac40720
4 files changed
+72
-2
No files matched your search
@@ -42,6 +42,31 @@ namespace PrivaPub.Tests.Federation
|
||||
|
||||
PrivaPub.Models.Statistics.InteractionEvent Processed(string activity) => _harness.Ledger.Of("in").Last(e => e.Activity == activity);
|
||||
|
||||
// Pixelfed names our post by its page (/@name/<id>, the post's url) in its Like, Announce and their Undo: the post is
|
||||
// found the same as by its id
|
||||
[Fact]
|
||||
public async Task A_like_naming_a_post_by_its_page_counts_and_its_undo_too()
|
||||
{
|
||||
var token = TestContext.Current.CancellationToken;
|
||||
var (_, alice) = await _harness.Persona("alice");
|
||||
var fan = new RemoteActor(_harness.Peer, "fan");
|
||||
var post = (await _harness.Statuses.Publish(alice, new StatusDraft { Text = "a picture" }, token)).Post;
|
||||
var page = alice.PostHtmlUrl(post.ID);
|
||||
Assert.NotEqual(post.ObjectURI, page);
|
||||
var like = new JsonObject { ["id"] = NewId(fan, "likes"), ["type"] = "Like", ["actor"] = fan.Id, ["object"] = page };
|
||||
|
||||
await _harness.Deliver(fan, "/human-centipede", like);
|
||||
Assert.Equal("accepted", Processed("Like").Outcome);
|
||||
Assert.Equal(1, (await DB.Default.Find<Post>().OneAsync(post.ID, token)).FavouritesCount);
|
||||
await _harness.Deliver(fan, "/human-centipede", Activity(fan, "Undo", like));
|
||||
Assert.Equal(0, (await DB.Default.Find<Post>().OneAsync(post.ID, token)).FavouritesCount);
|
||||
|
||||
// a page that is no post of ours stays as it is
|
||||
var elsewhere = new JsonObject { ["id"] = NewId(fan, "likes"), ["type"] = "Like", ["actor"] = fan.Id, ["object"] = alice.PostHtmlUrl("000000000000000000000000") };
|
||||
await _harness.Deliver(fan, "/human-centipede", elsewhere);
|
||||
Assert.Equal(("dropped", "unknown-object"), (Processed("Like").Outcome, Processed("Like").Reason));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task An_actor_update_refreshes_the_account_from_its_origin_even_when_its_updated_is_older()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user