fediverse

package
v0.4.7-0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 3, 2025 License: GPL-2.0 Imports: 9 Imported by: 0

README

Fediverse Bridge

This package implements ActivityPub protocol support for bridging NNTP newsgroups to the Fediverse (Mastodon, Pleroma, etc.).

Features

  • ActivityPub Server: Creates newsgroups as ActivityPub Group actors
  • Article Bridging: Converts NNTP articles to ActivityPub Notes
  • Federation Ready: Supports ActivityStreams vocabulary
  • HTTP Signatures: Prepared for authenticated federation (TODO)

Components

activitypub.go

Core ActivityPub protocol implementation:

  • ActivityPubServer - Main server instance
  • Actor - Represents newsgroups as Group actors
  • Note - Represents articles as ActivityPub Notes
  • Activity - Wraps actions (Create, Update, etc.)
bridge.go

Bridge management:

  • Bridge - Manages newsgroup registration and article bridging
  • Thread-safe operations with mutex protection
  • Enable/disable functionality

Usage

// Create bridge
bridge := fediverse.NewBridge("example.com", "https://example.com")
bridge.Enable()

// Register newsgroup
newsgroup := &models.Newsgroup{Name: "comp.lang.go", Description: "Go programming"}
bridge.RegisterNewsgroup(newsgroup)

// Bridge article
article := &models.Article{MessageID: "123@example.com", Subject: "Hello", BodyText: "World"}
bridge.BridgeArticle(article, "comp.lang.go")

ActivityPub Endpoints

When integrated, the following endpoints will be available:

  • GET /newsgroups/{name} - Newsgroup actor
  • GET /newsgroups/{name}/inbox - Receive activities
  • GET /newsgroups/{name}/outbox - Published activities
  • GET /newsgroups/{name}/followers - Follower collection
  • GET /articles/{messageId} - Individual article as Note

Configuration

Enable via command line:

./web --enable-fediverse --fediverse-domain=your.domain.com --fediverse-baseurl=https://your.domain.com

Standards Compliance

  • ActivityPub: W3C Recommendation for federated social networking
  • ActivityStreams 2.0: Vocabulary for social activities
  • HTTP Signatures: Authentication for server-to-server communication (planned)

Example ActivityPub Objects

Newsgroup Actor
{
  "@context": ["https://www.w3.org/ns/activitystreams"],
  "id": "https://example.com/newsgroups/comp.lang.go",
  "type": "Group",
  "preferredUsername": "comp.lang.go",
  "name": "comp.lang.go",
  "summary": "Go programming language discussion",
  "inbox": "https://example.com/newsgroups/comp.lang.go/inbox",
  "outbox": "https://example.com/newsgroups/comp.lang.go/outbox"
}
Article Note
{
  "id": "https://example.com/articles/123@example.com",
  "type": "Note",
  "summary": "Hello World",
  "content": "This is my first post!",
  "actor": "https://example.com/newsgroups/comp.lang.go",
  "published": "2025-07-09T12:00:00Z"
}

TODO

  • Implement HTTP signatures for authentication
  • Add webhook support for incoming activities
  • Support for replies and threading
  • WebFinger support for discovery
  • Rate limiting and security measures
  • Moderation tools integration

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Activity

type Activity struct {
	Context   []interface{} `json:"@context"`
	ID        string        `json:"id"`
	Type      string        `json:"type"`
	Actor     string        `json:"actor"`
	Object    interface{}   `json:"object"`
	Published time.Time     `json:"published"`
}

type ActivityPubServer

type ActivityPubServer struct {
	Domain     string
	PrivateKey *rsa.PrivateKey
	PublicKey  *rsa.PublicKey
	BaseURL    string
}

func NewActivityPubServer

func NewActivityPubServer(domain, baseURL string) *ActivityPubServer

func (*ActivityPubServer) ArticleToNote

func (aps *ActivityPubServer) ArticleToNote(article *models.Article, newsgroup string) *Note

func (*ActivityPubServer) CreateNewsgroupActor

func (aps *ActivityPubServer) CreateNewsgroupActor(newsgroup *models.Newsgroup) *Actor

func (*ActivityPubServer) SendActivity

func (aps *ActivityPubServer) SendActivity(targetInbox string, activity *Activity) error

type Actor

type Actor struct {
	Context           []interface{} `json:"@context"`
	ID                string        `json:"id"`
	Type              string        `json:"type"`
	PreferredUsername string        `json:"preferredUsername"`
	Name              string        `json:"name"`
	Summary           string        `json:"summary"`
	Inbox             string        `json:"inbox"`
	Outbox            string        `json:"outbox"`
	Followers         string        `json:"followers"`
	Following         string        `json:"following"`
	PublicKey         PublicKey     `json:"publicKey"`
}

type Bridge

type Bridge struct {
	// contains filtered or unexported fields
}

func NewBridge

func NewBridge(domain, baseURL string) *Bridge

func (*Bridge) BridgeArticle

func (b *Bridge) BridgeArticle(article *models.Article, newsgroup string) error

func (*Bridge) Disable

func (b *Bridge) Disable()

func (*Bridge) Enable

func (b *Bridge) Enable()

func (*Bridge) IsEnabled

func (b *Bridge) IsEnabled() bool

func (*Bridge) RegisterNewsgroup

func (b *Bridge) RegisterNewsgroup(newsgroup *models.Newsgroup) error

type Note

type Note struct {
	ID        string    `json:"id"`
	Type      string    `json:"type"`
	Summary   string    `json:"summary,omitempty"`
	Content   string    `json:"content"`
	Actor     string    `json:"actor"`
	To        []string  `json:"to"`
	CC        []string  `json:"cc,omitempty"`
	Published time.Time `json:"published"`
	Tag       []Tag     `json:"tag,omitempty"`
}

type PublicKey

type PublicKey struct {
	ID           string `json:"id"`
	Owner        string `json:"owner"`
	PublicKeyPem string `json:"publicKeyPem"`
}

type Tag

type Tag struct {
	Type string `json:"type"`
	Name string `json:"name"`
	Href string `json:"href,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL