Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(protocol/activitypub): rebuild activitypub engine protocol and provider #600

Merged
merged 39 commits into from
Nov 14, 2024

Conversation

FrankLi123
Copy link
Contributor

@FrankLi123 FrankLi123 commented Oct 22, 2024

Summary

This PR is about implementing the relay subscription solution for ActivityPub data collection. This solution is compatible with most of the common Relay URLs that either end with '/inbox' or without.

Guide: How to Run a Mastodon Worker locally ?

  • Get a Public URL endpoint forwarding to localhost:{port number} and input it as the mastodon endpoint in config.yaml. You can use a tool like Ngrok to expose a server at a port. e.g., "https://your-subdomain.ngrok.app".

  • Add a Relay service list and a port as a parameter in config.yaml for local development. Relays aggregate messages from different servers, and the port is where your input endpoint will forward requests. You can add multiple relay URLs in config.yaml or default relay URLs will be used if none are specified:

    • config.yaml -> component -> federated -> id: mastodon-core -> parameters
  • ex:

  federated:
    - id: mastodon-core
      network: mastodon
      worker: core
      endpoint: https://domain:port
      parameters:
        relay_url_list: ["https://relay.fedi.buzz/instance/mastodon.social","https://relay.intahnet.co.uk/inbox"]

Default Relay Service List:

"https://relay.toot.io/inbox",
"https://relay.infosec.exchange/inbox",
"https://relay.intahnet.co.uk/inbox",
"https://relay.fedi.buzz/instance/mas.to",
"https://relay.fedi.buzz/instance/mastodon.online",

(note): messages from relay.fedi.buzz server do not contain "share" type object.

Main Modified Components

  • mastodon/client.go: Functions for relay service interaction and received relay message handling
  • activitypub/data_source.go: implementation of the core data collection process with the HTTP server

Technical Implementation

  • HTTP Server: Built on Echo framework to handle ActivityPub endpoints
  • Mimic as a mastodon instance with Authentication: Dynamic RSA key pair generation for secure relay communication with other mastodon servers
  • Message Processing: In-memory message channel for ActivityPub object processing

Future Improvements:

  • Implement monitoring and client stability in another PR

Checklist

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@FrankLi123 FrankLi123 marked this pull request as draft October 22, 2024 15:57
@FrankLi123 FrankLi123 self-assigned this Oct 22, 2024
@brucexc brucexc requested review from kallydev and brucexc and removed request for brucexc, polebug and kallydev October 22, 2024 18:20
@FrankLi123 FrankLi123 marked this pull request as ready for review October 22, 2024 18:36
provider/activitypub/mastodon/client.go Outdated Show resolved Hide resolved
provider/activitypub/mastodon/client.go Outdated Show resolved Hide resolved
provider/activitypub/mastodon/client.go Outdated Show resolved Hide resolved
provider/activitypub/mastodon/client.go Outdated Show resolved Hide resolved
provider/activitypub/mastodon/client.go Outdated Show resolved Hide resolved
provider/activitypub/mastodon/client.go Show resolved Hide resolved
provider/activitypub/mastodon/client.go Show resolved Hide resolved
internal/node/monitor/client.go Outdated Show resolved Hide resolved
internal/engine/protocol/activitypub/data_source.go Outdated Show resolved Hide resolved
internal/engine/protocol/activitypub/data_source.go Outdated Show resolved Hide resolved
@brucexc brucexc requested a review from polebug October 23, 2024 04:04
@brucexc brucexc marked this pull request as draft October 23, 2024 04:41
@FrankLi123 FrankLi123 force-pushed the feat/rebuild-activitypub-engine-protocol-and-provider branch from b35d4fa to 215230f Compare October 24, 2024 16:50
@FrankLi123 FrankLi123 force-pushed the feat/rebuild-activitypub-engine-protocol-and-provider branch from 215230f to 412bb3d Compare October 24, 2024 17:36
@FrankLi123 FrankLi123 marked this pull request as draft October 29, 2024 19:04
@FrankLi123 FrankLi123 marked this pull request as ready for review October 30, 2024 06:46
provider/activitypub/mastodon/client.go Outdated Show resolved Hide resolved
@HenryQW
Copy link
Member

HenryQW commented Oct 30, 2024

Remember to update and close this: RSS3-Network/Docs#9

@brucexc
Copy link
Contributor

brucexc commented Nov 5, 2024

Remember to update and close this: RSS3-Network/Docs#9

Please pay attention to this comment: RSS3-Network/Docs#9 (comment).

@brucexc brucexc force-pushed the feat/rebuild-activitypub-engine-protocol-and-provider branch from 935c897 to e85e3aa Compare November 7, 2024 04:54
…-provider

# Conflicts:
#	internal/node/monitor/client.go
#	internal/node/monitor/monitor_mock.go
#	internal/node/monitor/monitor_test.go
@polebug polebug self-requested a review November 12, 2024 02:50
@brucexc brucexc merged commit 2c0a700 into main Nov 14, 2024
5 checks passed
@brucexc brucexc deleted the feat/rebuild-activitypub-engine-protocol-and-provider branch November 14, 2024 03:18
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.

5 participants