Skip to content

Conversation

@obenland
Copy link
Member

@obenland obenland commented Dec 3, 2025

Related to https://wordpress.org/support/topic/import-mastodon-beta/

Proposed changes:

  • Import Mastodon self-replies (thread continuations) as WordPress comments instead of separate posts
  • Preserve thread structure with proper comment threading for nested replies
  • External replies continue to be imported as posts with the reply block

Other information:

  • Have you written new tests for your changes, if applicable?

Testing instructions:

  • Export your Mastodon archive (Settings → Import and Export → Request your archive)
  • Go to Tools → Import → Mastodon
  • Upload the archive and run the import
  • Verify that:
    • Root posts are imported as WordPress posts
    • External replies (to other users) are imported as posts with reply block
    • Self-replies (thread continuations) are imported as comments on the parent post
    • Nested self-replies maintain proper threading (comment → reply to comment)

Changelog entry

  • Automatically create a changelog entry from the details below.
Changelog Entry Details

Significance

  • Patch
  • Minor
  • Major

Type

  • Added - for new features
  • Changed - for changes in existing functionality
  • Deprecated - for soon-to-be removed features
  • Removed - for now removed features
  • Fixed - for any bug fixes
  • Security - in case of vulnerabilities

Message

Mastodon importer now imports self-replies as comments, preserving thread structure.

Thread continuations (replies to own posts) are now imported as WordPress
comments on the parent post, preserving the thread structure. External
replies continue to be imported as posts with the reply block.

The import now uses a multi-pass approach:
- Pass 1: Categorize posts into regular posts and self-replies
- Pass 2: Import regular posts (root posts + external replies) as WP posts
- Pass 3: Import self-replies as comments, sorted by date for correct threading

Self-reply detection compares the actor URL with the inReplyTo URL to
determine if a post is a thread continuation.

Adds comprehensive tests for self-reply handling including:
- Basic self-replies as comments
- External replies as posts
- Nested thread threading (A → B → C)
- Orphaned self-replies handling
- Self-replies to external replies
Copilot AI review requested due to automatic review settings December 3, 2025 00:14
@obenland obenland self-assigned this Dec 3, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the Mastodon importer to intelligently distinguish between self-replies (thread continuations) and external replies, importing the former as WordPress comments while maintaining the latter as posts. This provides a more natural representation of threaded conversations in WordPress.

Key changes:

  • Self-replies are now imported as comments on their parent posts instead of separate posts
  • Nested self-reply threading is preserved with proper comment parent relationships
  • External replies continue to be imported as posts with reply blocks

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
includes/wp-admin/import/class-mastodon.php Refactored import logic to use a multi-pass approach: categorizing posts, importing regular posts, then importing self-replies as comments with proper threading support
tests/phpunit/tests/includes/wp-admin/import/class-test-mastodon.php Added comprehensive test coverage for self-reply scenarios including basic self-replies, external replies, nested threading, orphaned replies, and mixed patterns
.github/changelog/2572-from-description Added changelog entry documenting the new feature as a minor addition

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@obenland obenland requested a review from a team December 4, 2025 15:00
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 8 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Fix self-reply detection to prevent false positives with similar usernames
- Use more generic "Skipped comments:" message
- Add PHP version checks for setAccessible() in tests

Co-Authored-By: Claude <[email protected]>
@obenland obenland requested a review from pfefferle December 8, 2025 14:52
Copy link
Member

@pfefferle pfefferle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If @TheVoidTLMB is fine with it.

@obenland obenland merged commit c3f9db7 into trunk Dec 9, 2025
9 checks passed
@obenland obenland deleted the add/mastodon-import-self-replies-as-comments branch December 9, 2025 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants