bluesky

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2025 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BskyEndpoint     = "https://bsky.social"
	BskySubscribeURI = "wss://bsky.network/xrpc/com.atproto.sync.subscribeRepos"

	SyncListReposLimit = 10
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(_ context.Context, username string, password string, options ...Option) (*Client, error)

func (*Client) BuildURI

func (c *Client) BuildURI(did syntax.DID, collection string, rkey string) string

BuildURI constructs an AT Protocol URI from its components. Parameters: - did: Repository owner's DID - collection: Record collection identifier - rkey: Record key Returns complete URI in format "at://did/collection/rkey".

func (*Client) GetHandle

func (c *Client) GetHandle(ctx context.Context, client *XrpcClient, did syntax.DID) (string, error)

GetHandle retrieves the handle (username) for a given DID. Parameters: - did: User's decentralized identifier Returns the user's handle or an error.

func (*Client) GetRecord

func (c *Client) GetRecord(ctx context.Context, repo string, path string) (*at.Message, cbg.CBORMarshaler, error)

func (*Client) GetRepoRecord

func (c *Client) GetRepoRecord(ctx context.Context, repo string, path string) (*at.Message, error)

GetRepoRecord retrieves a specific record from a repository. Parameters: - repo: The DID of the repository - path: The path in format "collection/rkey" Returns the message containing the record data or an error.

func (*Client) GetXrpcClient

func (c *Client) GetXrpcClient(ctx context.Context, endpoint string) (*XrpcClient, error)

GetXrpcClient returns a cached or new authenticated XRPC client. Parameters: - endpoint: API endpoint URL to connect to Returns authenticated client or error if authentication fails.

func (*Client) LookupDIDEndpoint

func (c *Client) LookupDIDEndpoint(ctx context.Context, did syntax.DID) string

func (*Client) ParseCARList

func (c *Client) ParseCARList(ctx context.Context, did syntax.DID, handle string, repoBytes []byte) ([]*at.Message, error)

ParseCARList processes repository data in CAR format and extracts messages. Parameters: - did: Repository owner's DID - handle: User's handle - repoBytes: Raw CAR format repository data Returns list of processed messages from the repository.

func (*Client) ParseCreatedAt

func (c *Client) ParseCreatedAt(_ context.Context, createdAt string) (time.Time, bool)

func (*Client) ParsePath

func (c *Client) ParsePath(path string) (string, string)

ParsePath splits a path string into collection and rkey components. Parameters: - path: String in format "collection/rkey" Returns collection and rkey as separate strings.

func (*Client) ParseRecord

func (c *Client) ParseRecord(ctx context.Context, rec cbg.CBORMarshaler, message *at.Message) (bool, error)

ParseRecord processes different types of records and updates the message. Parameters: - rec: CBOR marshaled record to parse - message: Message struct to be updated with record data Returns error if record parsing fails.

func (*Client) ParseRepoStrongRef

func (c *Client) ParseRepoStrongRef(ctx context.Context, ref *atproto.RepoStrongRef) (*at.Message, error)

func (*Client) ParseURI

func (c *Client) ParseURI(uri string) (string, string)

ParseURI splits an AT Protocol URI into components. Parameters: - uri: Complete AT Protocol URI (format: at://did/collection/rkey) Returns the repository DID and the path.

func (*Client) SyncGetRepo

func (c *Client) SyncGetRepo(ctx context.Context, repoData *atproto.SyncListRepos_Repo) ([]*at.Message, error)

SyncGetRepo retrieves all records from a repository snapshot. Parameters: - repoData: Repository metadata including DID and status Returns list of messages containing the repository records.

func (*Client) SyncListRepos

func (c *Client) SyncListRepos(ctx context.Context, cursor string, limit int64) ([]*at.Message, *string, error)

SyncListRepos fetches a paginated list of repository updates. Parameters: - cursor: Pagination token, empty for first page - limit: Maximum number of repos to fetch Returns list of messages and the next cursor for pagination.

type Option

type Option func(client *Client) error

func WithFilter

func WithFilter(filter []string) Option

func WithTimestampStart

func WithTimestampStart(timestamp time.Time) Option

type XrpcClient

type XrpcClient struct {
	*xrpc.Client
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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