Skip to content

Conversation

@sij411
Copy link
Contributor

@sij411 sij411 commented Oct 19, 2025

Summary

This PR adds a LitePub-compatible ActivityPub relay implementation to the
@fedify/relay package, complementing the existing Mastodon relay implementation.

Related Issue

#359

Changes

  • Added LitePubRelay class in packages/relay/src/relay.ts:321-585 that implements
    the LitePub relay protocol
  • Implemented LitePub-specific activity handling:
    • Wraps incoming Create, Update, Move, and Delete activities in Announce
      activities before forwarding
    • Uses Application actor type instead of Mastodon's Service type
    • Sends announcements to PUBLIC_COLLECTION for broader visibility
  • Added comprehensive test suite for LitePubRelay in
    packages/relay/src/relay.test.ts:455-832 covering:
    • Relay initialization and configuration
    • Actor endpoint behavior (Application type)
    • Followers collection management
    • Subscription handler integration
    • Follow/Undo activity processing
    • Multiple follower support

Benefits

  • Protocol compatibility: Enables Fedify relay instances to work with
    LitePub-compatible fediverse software, which expects activities to be wrapped in
    Announce rather than directly forwarded
  • Broader reach: Using PUBLIC_COLLECTION as the audience for announces ensures
    better visibility across the fediverse
  • Developer choice: Developers can now choose between Mastodon-style
    (MastodonRelay) and LitePub-style (LitePubRelay) relay implementations based on
    their target ecosystem
  • Consistent API: Both relay implementations share the same Relay interface, making
    it easy to switch between protocols

Checklist

  • Did you add a changelog entry to the CHANGES.md?
  • Did you write some relevant docs about this change (if it's a new feature)?
  • Did you write a regression test to reproduce the bug (if it's a bug fix)?
  • Did you write some tests for this change (if it's a new feature)?
  • Did you run deno task test-all on your machine?

Additional Notes

Key differences between LitePub and Mastodon relay protocols:

  1. Actor type: LitePub uses Application, Mastodon uses Service
  2. Activity forwarding:
    - LitePub wraps activities in Announce objects with relay as actor
    - Mastodon forwards activities directly using ctx.forwardActivity()
  3. Audience: LitePub sends to PUBLIC_COLLECTION for maximum visibility

The implementation follows the same subscription management and key pair handling
as MastodonRelay, ensuring consistent behavior for core relay functionality like
follower management and subscription approvals.

@codecov
Copy link

codecov bot commented Nov 13, 2025

Codecov Report

❌ Patch coverage is 47.09898% with 155 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
packages/relay/src/relay.ts 47.09% 155 Missing ⚠️
Files with missing lines Coverage Δ
packages/relay/src/relay.ts 54.28% <47.09%> (-8.79%) ⬇️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dahlia
Copy link
Member

dahlia commented Nov 13, 2025

@sij411 Could you rebase your commits on the latest next branch?

@sij411 sij411 marked this pull request as ready for review November 14, 2025 01:15
@dahlia
Copy link
Member

dahlia commented Nov 14, 2025

@sij411 I fixed several packaging issues for @fedify/relay in the last commit (c31cc63) of the next branch. Could you rebase your commits on it once again?

Copy link
Member

@dahlia dahlia left a comment

Choose a reason for hiding this comment

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

It looks like there's quite a bit of duplicate code between MastodonRelay and LitePubRelay. How about we create an abstract base class, let's call it BaseRelay for now, move the shared code into it, and then have MastodonRelay and LitePubRelay inherit from BaseRelay?

@github-actions
Copy link
Contributor

github-actions bot commented Nov 14, 2025

The docs for this pull request have been published:

https://7c0acbfa.fedify.pages.dev

@sij411
Copy link
Contributor Author

sij411 commented Nov 14, 2025

It looks like there's quite a bit of duplicate code between MastodonRelay and LitePubRelay. How about we create an abstract base class, let's call it BaseRelay for now, move the shared code into it, and then have MastodonRelay and LitePubRelay inherit from BaseRelay?

That was my original plan, yes it is supposed be like that eventually. Do you think that should be done in this PR?

@dahlia
Copy link
Member

dahlia commented Nov 14, 2025

@sij411 Fair enough. Please refactor it in the next PR!

@dahlia
Copy link
Member

dahlia commented Nov 14, 2025

By the way, LitePubRelay should be tested with actual Pleroma/Akkoma instances.

@sij411
Copy link
Contributor Author

sij411 commented Nov 15, 2025

By the way, LitePubRelay should be tested with actual Pleroma/Akkoma instances.

I'll let you know test result when it's done. maybe in few days.

@sij411
Copy link
Contributor Author

sij411 commented Nov 18, 2025

As you know, we tested LitePub relay and checked 1) the relay server can be subscribed by two Akkoma instances (deployed with DigitalOcean Droplet), 2) the posts of relay subscribers are showed up on "Known Hosts" tab for each instance.

I think we could wrap up the LitePub relay protocol implementations, and refactor module structures and etc in another PR.

@github-actions
Copy link
Contributor

The latest push to this pull request has been published to JSR and npm as a pre-release:

Package Version JSR npm
@fedify/fedify 2.0.0-pr.471.1924+020b6605 JSR npm
@fedify/cli 2.0.0-pr.471.1924+020b6605 JSR npm
@fedify/amqp 2.0.0-pr.471.1924+020b6605 JSR npm
@fedify/cfworkers 2.0.0-pr.471.1924+020b6605 JSR npm
@fedify/denokv 2.0.0-pr.471.1924+020b6605 JSR
@fedify/elysia 2.0.0-pr.471.1924+020b6605 npm
@fedify/express 2.0.0-pr.471.1924+020b6605 JSR npm
@fedify/h3 2.0.0-pr.471.1924+020b6605 JSR npm
@fedify/hono 2.0.0-pr.471.1924+020b6605 JSR npm
@fedify/koa 2.0.0-pr.471.1924+020b6605 JSR npm
@fedify/nestjs 2.0.0-pr.471.1924+020b6605 npm
@fedify/next 2.0.0-pr.471.1924+020b6605 npm
@fedify/postgres 2.0.0-pr.471.1924+020b6605 JSR npm
@fedify/redis 2.0.0-pr.471.1924+020b6605 JSR npm
@fedify/sqlite 2.0.0-pr.471.1924+020b6605 JSR npm
@fedify/sveltekit 2.0.0-pr.471.1924+020b6605 JSR npm
@fedify/testing 2.0.0-pr.471.1924+020b6605 JSR npm

@sij411 sij411 deployed to github-pages November 18, 2025 16:04 — with GitHub Actions Active
@dahlia dahlia merged commit ffa60a7 into fedify-dev:next Nov 18, 2025
20 of 25 checks passed
@dahlia dahlia linked an issue Nov 18, 2025 that may be closed by this pull request
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.

The @fedify/relay package for ActivityPub relays

2 participants