Documentation ¶
Index ¶
- Constants
- func NewId(uris_table *uris.URIs, prefix string) string
- func ParseAddress(addr string) (string, string, error)
- func ParseAddressFromRequest(req *http.Request) (string, string, error)
- func ParseAddressesFromString(body string) ([]string, error)
- type Activity
- func NewAcceptActivity(ctx context.Context, uris_table *uris.URIs, from string, object interface{}) (*Activity, error)
- func NewAnnounceActivity(ctx context.Context, uris_table *uris.URIs, from string, author_addr string, ...) (*Activity, error)
- func NewBoostActivity(ctx context.Context, uris_table *uris.URIs, from string, author_addr string, ...) (*Activity, error)
- func NewBoostActivityForNote(ctx context.Context, uris_table *uris.URIs, from string, note_uri string) (*Activity, error)
- func NewCreateActivity(ctx context.Context, uris_table *uris.URIs, from string, to []string, ...) (*Activity, error)
- func NewFollowActivity(ctx context.Context, uris_table *uris.URIs, from string, to string) (*Activity, error)
- func NewUndoFollowActivity(ctx context.Context, uris_table *uris.URIs, from string, to string) (*Activity, error)
- type Actor
- type Attachment
- type Followers
- type Following
- type Icon
- type Note
- type OrderedCollection
- type PostToInboxOptions
- type PublicKey
- type Tag
Constants ¶
const ACCEPT_ACTIVITY string = "Accept"
const ACTIVITYSTREAMS_ACCEPT_HEADER string = `application/ld+json; profile="https://www.w3.org/ns/activitystreams"`
Deprecated, please use ACTIVITYSTREAMS_ACCEPT_HEADER
const ACTIVITYSTREAMS_CONTEXT string = "https://www.w3.org/ns/activitystreams"
const ACTIVITYSTREAMS_CONTEXT_PUBLIC string = "https://www.w3.org/ns/activitystreams#Public"
const ACTIVITY_CONTENT_TYPE string = "application/activity+json"
const ACTIVITY_LD_CONTENT_TYPE string = `application/ld+json; profile="https://www.w3.org/ns/activitystreams"`
const CREATE_ACTIVITY string = "Create"
const FOLLOW_ACTIVITY string = "Follow"
Variables ¶
This section is empty.
Functions ¶
func ParseAddressFromRequest ¶ added in v0.0.2
func ParseAddressesFromString ¶ added in v0.0.2
Types ¶
type Activity ¶
type Activity struct { // Context needs to be a "whatever" (interface{}) because ActivityPub (JSON-LD) // mixes and matches string URIs, arbritrary data structures and arrays of string // URIs and arbritrary data structures in @context... Context interface{} `json:"@context,omitempty"` // Id is the unique identifier for the activity. Id string `json:"id"` // Type is the name of the activity being performed. Type string `json:"type"` // Actor is the URI of the person (actor) performing the activity. Note: This is a fully-qualified "profile" URI and not a "@user@host" address. Actor string `json:"actor"` // To is the list of URIs the activity should be delivered to. Note: The fact that this can be something like [ "https://www.w3.org/ns/activitystreams#Public" ] makes me wonder what the point of this property is (since the relevant issue is the inbox that the encoded activity is delivered to). To []string `json:"to,omitempty"` // CC is the list of URIs the activity should be copied to. Note: It's not clear what the point of this unless the purpose of this property (and the "To" property) is for an activity to double as a complete record, inclusive of every address it should be delivered to, that can be scheduled for asynchronous delivery. Cc []string `json:"cc,omitempty"` // Audience limits visibility to just the specified users. Audience string `json:"audience,omitempty"` // Object is body of the activity itself. Object interface{} `json:"object,omitempty"` // The RFC3339 date that the activity was published. Published string `json:"published,omitempty"` }
Activity is a struct encapsulating an ActivityPub activity.
func NewAcceptActivity ¶
func NewAcceptActivity(ctx context.Context, uris_table *uris.URIs, from string, object interface{}) (*Activity, error)
NewAcceptActvity returns a new `Activity` instance of type "Accept". The Accept activity "indicates that the actor accepts the object. The target property can be used in certain circumstances to indicate the context into which the object has been accepted."
func NewAnnounceActivity ¶
func NewAnnounceActivity(ctx context.Context, uris_table *uris.URIs, from string, author_addr string, object interface{}) (*Activity, error)
NewAnnounceActivity will return an ActivityPub "Announce" activity from 'from' about 'object' (created by 'author_addr').
func NewBoostActivity ¶
func NewBoostActivity(ctx context.Context, uris_table *uris.URIs, from string, author_addr string, object interface{}) (*Activity, error)
NewBoostActivity will return an ActivityPub "Announce" activity from 'from' about 'object' (created by 'author_addr').
func NewBoostActivityForNote ¶ added in v0.0.2
func NewCreateActivity ¶
func NewCreateActivity(ctx context.Context, uris_table *uris.URIs, from string, to []string, object interface{}) (*Activity, error)
NewCreateActivity returns a new `Activity` instance of type "Create".
func NewFollowActivity ¶
func NewFollowActivity(ctx context.Context, uris_table *uris.URIs, from string, to string) (*Activity, error)
NewCreateActivity returns a new `Activity` instance of type "Follow".
func NewUndoFollowActivity ¶
func (*Activity) PostToInbox ¶ added in v0.0.2
func (activity *Activity) PostToInbox(ctx context.Context, key_id string, private_key *rsa.PrivateKey, inbox_uri string) error
PostToInbox delivers an Activity message to a specific inbox.
type Actor ¶
type Actor struct { // It has to be an interface because JSON-LD... thanks, JSON-LD... Context []interface{} `json:"@context"` Id string `json:"id"` Type string `json:"type"` PreferredUsername string `json:"preferredUsername"` Inbox string `json:"inbox"` Outbox string `json:"outbox"` PublicKey PublicKey `json:"publicKey"` Following string `json:"following,omitempty"` Followers string `json:"followers,omitempty"` Name string `json:"name,omitempty"` Summary string `json:"summary,omitempty"` URL string `json:"url,omitempty"` // Don't omitempty because if you do then false values are omitted // ManuallyApprovesFollowers bool `json:"manuallyApprovesFollowers"` Discoverable bool `json:"discoverable,omitempty"` Published string `json:"published,omitempty"` Icon Icon `json:"icon,omitempty"` Attachments []*Attachment `json:"attachment,omitempty"` // Is this just a Mastodon-ism? }
func RetrieveActor ¶ added in v0.0.2
func RetrieveActorWithProfileURL ¶ added in v0.0.2
type Attachment ¶
type Note ¶
type Note struct { // Type is the type of the note (aka "Note"). Type string `json:"type"` // Id is the unique identifier for the note. Id string `json:"id"` // The URI of the actor that the note is attributed to. AttributedTo string `json:"attributedTo"` // ... InReplyTo string `json:"inReplyTo,omitempty"` // Zero or more tags associated with the note. Tags []*Tag `json:"tag,omitempty"` // To is the list of URIs the activity should be delivered to. To []string `json:"to"` // CC is the list of URIs the activity should be copied to. Cc []string `json:"cc,omitempty"` // The body of the note. Content string `json:"content"` // The permanent URL of the post. URL string `json:"url"` // The RFC3339 date that the activity was published. Published string `json:"published"` // Zero or more attachments to include with the note. Attachments []*Attachment `json:"attachment,omitempty"` }
type OrderedCollection ¶
type OrderedCollection struct { // It has to be an interface because JSON-LD... thanks, JSON-LD... Context []interface{} `json:"@context"` Id string `json:"id"` Summary string `json:"summary,omitempty"` Type string `json:"type"` TotalItems int `json:"totalItems"` OrderedItem []*interface{} `json:"orderedItems,omitempty"` }
type PostToInboxOptions ¶ added in v0.0.2
type PostToInboxOptions struct { // KeyId is a pointer (URI) to the actor/profile page where the public key of the actor posting the activity can be retrieved. KeyId string // The private key of the actor posting the activity used to sign the message. PrivateKey *rsa.PrivateKey // The URL of the inbox where the Activity should be posted. Inbox string // Log POST requests before they are sent using the default [log/slog] Logger. Note that this will // include the HTTP signature sent with the request so you should apply all the necessary care that // these values are logged somewhere you don't want unauthorized eyes to see the. LogRequest bool // Log the body of the POST response if it contains a status code that is not 200-202 or 204 using // the default [log/slog] Logger LogResponseOnError bool }