Documentation
¶
Index ¶
- Variables
- func CheckHeaders(c *fiber.Ctx, id string) error
- func CreatePem(id string) ([]byte, error)
- func MergeOutbox(ctx context.Context, board string, ob Outbox) error
- func NewProxy(proxyUrl string) (proxy, error)
- func PostDel(ctx context.Context, board database.Board, post database.Post) error
- func PostOut(ctx context.Context, board database.Board, post database.Post) error
- func PublicKey(id string) (string, error)
- func SendActivity(ctx context.Context, act Activity) error
- func Sign(id string, data string) (string, error)
- func Verify(keyPem string, sign string, data string) error
- type Activity
- type Actor
- type Collection
- type Link
- type LinkActor
- type LinkObject
- type Object
- type OrderedCollection
- type Outbox
- type StringList
Constants ¶
This section is empty.
Variables ¶
var Context = StringList{"https://www.w3.org/ns/activitystreams"}
var DB database.Database
var Proxy proxy
Functions ¶
func CheckHeaders ¶
Types ¶
type Actor ¶
type Actor struct { *Object PublicKey *publicKey `json:"publicKey,omitempty"` Inbox string `json:"inbox,omitempty"` Outbox string `json:"outbox,omitempty"` Following string `json:"following,omitempty"` Followers string `json:"followers,omitempty"` PreferredUsername string `json:"preferredUsername,omitempty"` Restricted bool `json:"restricted"` }
func TransformBoard ¶
type Collection ¶
type Collection struct { *Object TotalItems int `json:"totalItems"` Items []LinkObject `json:"items,omitempty"` }
Collection is a collection of links or objects.
func (Collection) MarshalJSON ¶
func (c Collection) MarshalJSON() ([]byte, error)
type Link ¶
Link represents a link to an Object. This may be just a raw string; in which case, Href will be the only thing set. There are other properties in here, but we don't care about them.
func (Link) MarshalJSON ¶
func (*Link) UnmarshalJSON ¶
type LinkActor ¶
type LinkActor Actor
LinkActor is for cases where there may either be a Link or an Actor. Links can be a full Link object, or just a string. Actors must be a full Object.
func (*LinkActor) MarshalJSON ¶
func (*LinkActor) UnmarshalJSON ¶
type LinkObject ¶
type LinkObject Object
LinkObject is for cases where there may either be a Link or an Object. Links can be a full Link object, or just a string. Objects must be a full Object.
func (*LinkObject) MarshalJSON ¶
func (l *LinkObject) MarshalJSON() ([]byte, error)
func (*LinkObject) UnmarshalJSON ¶
func (l *LinkObject) UnmarshalJSON(data []byte) error
type Object ¶
type Object struct { Context StringList `json:"@context,omitempty"` ID string `json:"id,omitempty"` Type string `json:"type,omitempty"` AttributedTo *LinkObject `json:"attributedTo,omitempty"` Content string `json:"content,omitempty"` InReplyTo []LinkObject `json:"inReplyTo,omitempty"` Name string `json:"name,omitempty"` Published *time.Time `json:"published,omitempty"` Replies *OrderedCollection `json:"replies,omitempty"` Summary string `json:"summary,omitempty"` To []LinkObject `json:"to,omitempty"` Updated *time.Time `json:"updated,omitempty"` // Extended attributes for other types Tripcode string `json:"tripcode,omitempty"` Subject string `json:"subject,omitempty"` Options []string `json:"option,omitempty"` // Should be plural but it's not Actor *LinkActor `json:"actor,omitempty"` // Hack to prevent collapsing objects because FChannel can't read them NoCollapse bool `json:"-"` }
Object is the base type for all things ActivityPub. A small subset is used since we don't care about 90% of it.
func TransformPost ¶
func TransformPost(ctx context.Context, actor *Actor, p database.Post, irt Object, fetchReplies bool, fetchInReplyTo bool) (Object, error)
TransformPost converts our native post structure to ActivityPub's Note.
type OrderedCollection ¶
type OrderedCollection struct { *Object TotalItems int `json:"totalItems"` OrderedItems []LinkObject `json:"orderedItems,omitempty"` }
OrderedCollection is a strictly ordered collection of links or objects. It exists solely because encoding/json won't do two JSON keys for one value, and I don't want to start pulling keys out of map[string]any returned from Unmarshal.
func (OrderedCollection) MarshalJSON ¶
func (c OrderedCollection) MarshalJSON() ([]byte, error)
type Outbox ¶
type Outbox struct { Context StringList `json:"@context,omitempty"` Actor *Actor `json:"actor,omitempty"` TotalItems int `json:"totalItems"` OrderedItems []LinkObject `json:"orderedItems,omitempty"` }
type StringList ¶
type StringList []string
StringList is a type that takes either a string, or a []string. In the case of string, index 0 will be said string.
func (StringList) MarshalJSON ¶
func (s StringList) MarshalJSON() ([]byte, error)
func (*StringList) UnmarshalJSON ¶
func (s *StringList) UnmarshalJSON(data []byte) error