Skip to content

Enable Mastodon Apps: Add tags.pub integration for tag timelines#3151

Merged
pfefferle merged 12 commits intotrunkfrom
add/tags-pub-tag-timeline
Apr 9, 2026
Merged

Enable Mastodon Apps: Add tags.pub integration for tag timelines#3151
pfefferle merged 12 commits intotrunkfrom
add/tags-pub-tag-timeline

Conversation

@akirk
Copy link
Copy Markdown
Member

@akirk akirk commented Apr 7, 2026

Summary

This will allow to view tags from inside a Mastodon app.

Proposed changes:

  • Supplement tag timelines with posts from across the Fediverse via tags.pub
  • Fetch the outbox of tags.pub actors (e.g. @wordpress@tags.pub), resolve Announce activities to their original posts, and convert them to Mastodon API Status entities
  • Reuse existing activity_to_status() and get_account_for_actor() methods
  • Cache results for 15 minutes (failures for 5 minutes)
  • Cap batch size at 5 items since each requires multiple HTTP round-trips (Announce → original post → author actor)

Other information:

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

Testing instructions:

  • Enable the Enable Mastodon Apps plugin (requires Add /api/v1/tags/:name endpoint akirk/enable-mastodon-apps#293)
  • Connect a Mastodon client (e.g. Tusky)
  • Browse a tag timeline (e.g. #wordpress) and verify remote posts from tags.pub appear
  • Verify statuses have proper account data (avatar, display name, acct)
  • Verify cached results load quickly on subsequent requests
  • Verify non-existent tags gracefully return empty results

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

Enable Mastodon Apps: Add tags.pub integration to supplement tag timelines with posts from across the Fediverse.

Copilot AI review requested due to automatic review settings April 7, 2026 11:48
@github-actions github-actions bot added the [Focus] Compatibility Ensuring the plugin plays well with other plugins label Apr 7, 2026
Copy link
Copy Markdown

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

Note

Copilot was unable to run its full agentic suite in this review.

Adds tags.pub enrichment to Mastodon tag timelines by fetching and resolving remote Announce activities into additional statuses, with short-term caching.

Changes:

  • Add a mastodon_api_tag_timeline filter to append remote statuses from tags.pub.
  • Implement outbox fetch + Announce resolution (original object + author actor) using existing conversion helpers.
  • Cache successful results for 15 minutes and failures for 5 minutes.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
integration/class-enable-mastodon-apps.php Implements tags.pub fetching/resolution and merges remote statuses into tag timeline responses with caching.
.github/changelog/3151-from-description Adds changelog entry for the new feature.

@akirk akirk changed the title Add tags.pub integration for tag timelines Enable Mastodon Apps: Add tags.pub integration for tag timelines Apr 7, 2026
akirk and others added 5 commits April 9, 2026 08:10
Fetch the outbox of tags.pub actors (e.g. @WordPress@tags.pub) to
supplement tag timelines with posts from across the Fediverse.

Each Announce activity is resolved to its original post and converted
to a Mastodon API Status entity using the existing activity_to_status()
and get_account_for_actor() methods. Results are cached for 15 minutes.

The batch size is capped at 5 items regardless of client-requested limit
since each item requires multiple HTTP round-trips to resolve.

See: https://activitypub.blog/2026/04/02/discover-more-of-the-fediverse-with-tags-pub/
Pass the ap_actor post ID directly to actor_to_account() instead
of relying on Actor::get__id(), which returns null for remote
actors because the Actor base class does not declare the $_id
property. This avoids falling back to URI strings that then get
remapped via the EMA remap taxonomy.
- Fix extra spaces in api_status_by_url docblock param alignment
- Use apply_filters instead of direct method call in api_search_by_url
  so third-party plugins can hook into mastodon_api_status_by_url
@pfefferle pfefferle force-pushed the add/tags-pub-tag-timeline branch from f5298b2 to cb9de8c Compare April 9, 2026 06:12
@pfefferle
Copy link
Copy Markdown
Member

@akirk can you address the co-pilot concerns?

akirk added 3 commits April 9, 2026 09:20
Storing Status objects in transients is brittle — PHP object
serialization can break across deployments when classes change.

Cache the resolved ActivityPub data (plain arrays with 'object'
and 'actor_uri' keys) and build Status entities fresh on each
read via the existing activity_to_status() pipeline.
The mastodon_api_tag_timeline filter receives and returns Status[],
not WP_REST_Response. Remove the unnecessary WP_REST_Response
handling and instanceof checks.
The mastodon_api_tag_timeline filter actually receives a
WP_REST_Response (from EMA's get_posts()), not Status[].
Handle this correctly and preserve the response object.
@akirk
Copy link
Copy Markdown
Member Author

akirk commented Apr 9, 2026

Oh, I missed that. Addressed!

akirk and others added 3 commits April 9, 2026 11:11
When merging local and tags.pub statuses, the same post could appear
in both sources, producing duplicate IDs that crash Tusky's LazyColumn.
- Fix alignment warning for $seen variable.
- Make tags.pub base URL filterable via activitypub_tags_pub_base_url.
- Add defensive type check in sort callback to prevent fatal errors
  when merged items are not Status objects.
@pfefferle pfefferle merged commit cca26a8 into trunk Apr 9, 2026
10 checks passed
@pfefferle pfefferle deleted the add/tags-pub-tag-timeline branch April 9, 2026 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Focus] Compatibility Ensuring the plugin plays well with other plugins [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants