pkg

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Authorize

func Authorize(ctx context.Context, credentials_ *Credentials) error

func CreateClient

func CreateClient(credentials *Credentials) (*mastodon.Client, error)

func CreateClientAndAuthenticate

func CreateClientAndAuthenticate(ctx context.Context, credentials *Credentials) (*mastodon.Client, error)

func ExtractID

func ExtractID(status string) string

ExtractID matches [0-9]+ in a string and returns the matched value

func InitConfig

func InitConfig()

func StoreCredentials

func StoreCredentials(credentials *Credentials) error

Types

type Credentials

type Credentials struct {
	Server      string
	GrantToken  string
	Application *mastodon.Application
	AccessToken string
}

Credentials stores the result of an oauth flow.

func LoadCredentials

func LoadCredentials() (*Credentials, error)

type Node

type Node struct {
	ID          mastodon.ID
	Ancestors   *orderedmap.OrderedMap[mastodon.ID, *Node]
	Descendants *orderedmap.OrderedMap[mastodon.ID, *Node]
	Status      *mastodon.Status
}

type Thread

type Thread struct {
	Nodes map[mastodon.ID]*Node
}

func (*Thread) AddContextAndGetMissingIDs

func (t *Thread) AddContextAndGetMissingIDs(id mastodon.ID, context *mastodon.Context)

AddContextAndGetMissingIDs adds the given context of the given status to the thread. Returns the list of missing IDs to be added.

func (*Thread) AddStatus

func (t *Thread) AddStatus(status *mastodon.Status)

func (*Thread) GetNode

func (t *Thread) GetNode(id mastodon.ID) *Node

GetNode returns the tree node for the given ID, creating it if not already present.

func (*Thread) GetRoots

func (t *Thread) GetRoots() []*Node

GetRoots returns the roots (nodes without ancestors) of the thread, in order.

func (*Thread) OutputToProcessor

func (t *Thread) OutputToProcessor(ctx context.Context, gp middlewares.Processor) error

func (*Thread) WalkBreadthFirst

func (t *Thread) WalkBreadthFirst(f func(n *Node, depth int, siblingIdx int) error) error

WalkBreadthFirst walks the thread in order, calling the given function on each node.

func (*Thread) WalkDepthFirst

func (t *Thread) WalkDepthFirst(f func(n *Node, depth int, siblingIdx int) error) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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