Skip to content

Fix ActivityPub replies to local comments not threading - #654

Open
akirk wants to merge 2 commits into
mainfrom
fix/activitypub-threaded-comment-replies
Open

Fix ActivityPub replies to local comments not threading#654
akirk wants to merge 2 commits into
mainfrom
fix/activitypub-threaded-comment-replies

Conversation

@akirk

@akirk akirk commented Apr 14, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fix replies from the Fediverse to local WordPress comments, federated as ?c=NNN URLs, so they arrive as threaded comments on the cached Friends post.
  • Prevent local comment URLs from being misresolved by url_to_postid() before ActivityPub can fall back to url_to_commentid().
  • Let ActivityPub persist inbound interaction comments on ActivityPub-capable friend_post_cache posts only while handling the inbound Create activity, while keeping cached posts disabled for the normal ActivityPub post lifecycle.
  • Defer Friends feed-item creation for replies to local comments so ActivityPub's comment handler can process them.
  • Fix comment reply links on friend_post_cache posts to use the local Friends URL instead of the external source URL.
  • Extend remote comment fetching to ActivityPub-capable cached posts and dedupe comments that are already stored locally.
  • Add regression tests for the comment URL handling, ActivityPub comment persistence, Friends deferral, reply-link URL, and remote-comment deduplication.

Test plan

  • composer test -- --filter ActivityPubTest
  • composer check-cs
  • Comment on a friend's post that originates from an ActivityPub-capable source.
  • Have someone reply to that comment from the Fediverse.
  • Verify the reply arrives as a threaded comment on the correct Friends post, not as a standalone cached post.
  • Verify the "Reply" link on comments uses the local Friends URL, not the external source URL.
  • Verify remote comments load without duplicating locally stored comments.

Test in WordPress Playground

Changelog
  • Automatically create a changelog entry from the details below

Type

  • Fixed

Message

Fix ActivityPub replies to local comments not arriving as threaded comments

@akirk

akirk commented Apr 15, 2026

Copy link
Copy Markdown
Owner Author

@pfefferle I am trying to debug this problem on my personal homepage. I believe this section is problematic:

https://github.com/Automattic/wordpress-activitypub/blob/6821a2b1be700b24d1064785aa358de375770901/includes/collection/class-interactions.php#L74-L82

url_to_postid for a comment url a la home_url( '?c=' . $comment_id ) strips the parameters off and then matches against the homepage. In my case a static page.

Thus, it doesn't return something falsy and thus doesn't go into the fallback. Is this is an oversight? My fix in this PR is to make sure url_to_postid() returns something false by making the URL invalid. But I think it could be solved more elegantly in the ActivityPub plugin.

My case in the friends plugin might be even a bit more complicated because I am replying in the Friends backend to a not-ActivityPub enabled post (it was federated in but it's a friend_post_cache) but I think it's a valid case for overriding activitypub_is_post_disabled, so that makes it work!

@akirk

akirk commented Apr 29, 2026

Copy link
Copy Markdown
Owner Author

@pfefferle maybe you missed this?

@akirk
akirk force-pushed the fix/activitypub-threaded-comment-replies branch from 7b3a0cf to 1aa298b Compare July 7, 2026 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant