sdk

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2024 License: CC0-1.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InputToEventPointer

func InputToEventPointer(input string) *pointers.EventPointer

InputToEventPointer turns any note/nevent/hex input into a EventPointer (or nil).

func InputToProfile

func InputToProfile(c context.T, input string) *pointers.ProfilePointer

InputToProfile turns any npub/nprofile/hex/nip05 input into a ProfilePointer (or nil).

Types

type Follow

type Follow struct {
	Pubkey  string
	Relay   string
	Petname string
}

type ProfileMetadata

type ProfileMetadata struct {
	PubKey string   `json:"-"` // must always be set otherwise things will break
	Event  *event.T `json:"-"` // may be empty if a profile metadata event wasn't found

	// every one of these may be empty
	Name        string `json:"name,omitempty"`
	DisplayName string `json:"display_name,omitempty"`
	About       string `json:"about,omitempty"`
	Website     string `json:"website,omitempty"`
	Picture     string `json:"picture,omitempty"`
	Banner      string `json:"banner,omitempty"`
	NIP05       string `json:"nip05,omitempty"`
	LUD16       string `json:"lud16,omitempty"`
}

func FetchProfileMetadata

func FetchProfileMetadata(c context.T, pool *pools.SimplePool, pubkey string, relays ...string) ProfileMetadata

func ParseMetadata

func ParseMetadata(event *event.T) (meta ProfileMetadata, e error)

func (ProfileMetadata) Nprofile

func (p ProfileMetadata) Nprofile(c context.T, sys *System, nrelays int) string

func (ProfileMetadata) Npub

func (p ProfileMetadata) Npub() string

func (ProfileMetadata) ShortName

func (p ProfileMetadata) ShortName() string

type Reference

type Reference struct {
	Text    string
	Start   int
	End     int
	Profile *pointers.ProfilePointer
	Event   *pointers.EventPointer
	Entity  *pointers.EntityPointer
}

func ParseReferences

func ParseReferences(evt *event.T) []*Reference

ParseReferences parses both NIP-08 and NIP-27 references in a single unifying interface.

type Relay

type Relay struct {
	URL    string
	Inbox  bool
	Outbox bool
}

func FetchRelaysForPubkey

func FetchRelaysForPubkey(c context.T, pool *pools.SimplePool, pubkey string, relays ...string) []Relay

func ParseRelaysFromKind3

func ParseRelaysFromKind3(evt *event.T) []Relay

func ParseRelaysFromKind10002

func ParseRelaysFromKind10002(evt *event.T) []Relay

type System

type System struct {
	RelaysCache      cache.Cache32[[]Relay]
	FollowsCache     cache.Cache32[[]Follow]
	MetadataCache    cache.Cache32[ProfileMetadata]
	Pool             *pools.SimplePool
	RelayListRelays  []string
	FollowListRelays []string
	MetadataRelays   []string
	Store            eventstore.Store
}

func (*System) ExpandQueriesByAuthorAndRelays

func (sys *System) ExpandQueriesByAuthorAndRelays(
	c context.T,
	f filter.T,
) (map[*relays.Relay]filter.T, error)

func (System) FetchOrStoreProfileMetadata

func (sys System) FetchOrStoreProfileMetadata(c context.T, pubkey string) ProfileMetadata

FetchOrStoreProfileMetadata is like FetchProfileMetadata, but also saves the result to the sys.Store

func (System) FetchOutboxRelays

func (sys System) FetchOutboxRelays(c context.T, pubkey string) []string

func (System) FetchProfileMetadata

func (sys System) FetchProfileMetadata(c context.T, pubkey string) ProfileMetadata

FetchProfileMetadata fetches metadata for a given user from the local cache, or from the local store, or, failing these, from the target user's defined outbox relays -- then caches the result.

func (System) FetchRelays

func (sys System) FetchRelays(c context.T, pubkey string) []Relay

func (System) FetchUserEvents

func (sys System) FetchUserEvents(c context.T, filt filter.T) (map[string][]*event.T, error)

FetchUserEvents fetches events from each users' outbox relays, grouping queries when possible.

func (System) StoreRelay

func (sys System) StoreRelay() eventstore.RelayInterface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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