Documentation
¶
Index ¶
Constants ¶
const ( ActivityStreamsContext = "https://www.w3.org/ns/activitystreams" SecurityV1Context = "https://w3id.org/security/v1" ActivityStreamsPublicContext = "https://www.w3.org/ns/activitystreams#Public" )
ActivityPub standard contexts and public addressing
const ( InReplyTo = "inReplyTo" TagType = "type" TagName = "name" Attachment = "attachment" AttachmentURL = "url" AttachmentMediaType = "mediaType" Tag = "tag" TagTypeHashtag = "Hashtag" TagTypeMention = "Mention" )
ActivityPub message properties and types
const (
ActivitySuffix = "/activity"
)
HTTP paths and headers
const DefaultServerPort = 8181
DefaultServerPort is the server port
Variables ¶
var DefaultRelayURLList = []string{
"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",
}
DefaultRelayURLList is a list of hardcoded relay URLs to follow
Functions ¶
func MessageTypeStrings ¶
func MessageTypeStrings() []string
MessageTypeStrings returns a slice of all String values of the enum
Types ¶
type Client ¶
type Client interface {
// FollowRelayServices attempts to follow all configured relay services.
// Returns error if any relay service fails to respond.
FollowRelayServices(ctx context.Context) error
// GetMessageChan returns a channel for receiving relay messages.
// Returns error if the message channel is not initialized.
GetMessageChan() (<-chan string, error)
// FetchAnnouncedObject retrieves an ActivityPub object from the specified URL.
// Returns the fetched object and any error encountered during the fetch.
FetchAnnouncedObject(ctx context.Context, objectURL string) (*activitypub.Object, error)
// GetActor returns the ActivityPub actor.
GetActor() (*activitypub.Actor, error)
// SendMessage queues a message to be processed.
SendMessage(object string)
}
func NewClient ¶
func NewClient(ctx context.Context, endpoint string, relayList []string, port int64, errorChan chan<- error) (Client, error)
NewClient creates a new Mastodon client with the specified public endpoint (domain) and relay URLs (relayURLList).
domain: This is the public URL of your server. It should be accessible to external services to enable federated communication. You can use a tool like Ngrok to expose a server at port 8181. e.g., "https://your-subdomain.ngrok.app". You can set it in config.yaml: config.yaml -> endpoints
relayList: A slice of URLs representing relay services to follow. Relays aggregate messages from different servers, allowing your server to stay updated with other servers in the network.
You can add multiple relay URLs in config.yaml: config.yaml -> component -> federated -> id: mastodon-core -> parameters -> relay_url_list
type MessageType ¶
type MessageType int
const ( MessageTypeNone MessageType = iota // Invalid default value MessageTypeCreate // Create ActivityPub message MessageTypeAnnounce // Announce ActivityPub message MessageTypeLike // Like ActivityPub message )
func MessageTypeString ¶
func MessageTypeString(s string) (MessageType, error)
MessageTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
func MessageTypeValues ¶
func MessageTypeValues() []MessageType
MessageTypeValues returns all values of the enum
func (MessageType) IsAMessageType ¶
func (i MessageType) IsAMessageType() bool
IsAMessageType returns "true" if the value is listed in the enum definition. "false" otherwise
func (MessageType) String ¶
func (i MessageType) String() string
func (MessageType) Values ¶
func (MessageType) Values() []string