sdk

package
v0.37.4 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2024 License: MIT Imports: 21 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InputToEventPointer

func InputToEventPointer(input string) *nostr.EventPointer

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

func InputToProfile

func InputToProfile(ctx context.Context, input string) *nostr.ProfilePointer

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

func IsVirtualRelay added in v0.36.0

func IsVirtualRelay(url string) bool

IsVirtualRelay returns true if the given normalized relay URL shouldn't be considered for outbox-model calculations.

Types

type EventResult added in v0.36.0

type EventResult dataloader.Result[*nostr.Event]

type Follow added in v0.36.0

type Follow struct {
	Pubkey  string
	Relay   string
	Petname string
}

func (Follow) Value added in v0.36.0

func (f Follow) Value() string

type FollowList added in v0.36.0

type FollowList = GenericList[Follow]

type GenericList added in v0.36.0

type GenericList[I TagItemWithValue] struct {
	PubKey string       `json:"-"` // must always be set otherwise things will break
	Event  *nostr.Event `json:"-"` // may be empty if a contact list event wasn't found

	Items []I
}

type MuteList added in v0.36.0

type MuteList = GenericList[Follow]

type ProfileMetadata added in v0.36.0

type ProfileMetadata struct {
	PubKey string       `json:"-"` // must always be set otherwise things will break
	Event  *nostr.Event `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 ParseMetadata added in v0.36.0

func ParseMetadata(event *nostr.Event) (meta ProfileMetadata, err error)

func (ProfileMetadata) Nprofile added in v0.36.0

func (p ProfileMetadata) Nprofile(ctx context.Context, sys *System, nrelays int) string

func (ProfileMetadata) Npub added in v0.36.0

func (p ProfileMetadata) Npub() string

func (ProfileMetadata) NpubShort added in v0.36.0

func (p ProfileMetadata) NpubShort() string

func (ProfileMetadata) ShortName added in v0.36.0

func (p ProfileMetadata) ShortName() string

type Reference added in v0.15.2

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

func ParseReferences added in v0.15.2

func ParseReferences(evt *nostr.Event) []*Reference

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

type Relay added in v0.19.3

type Relay struct {
	URL    string
	Inbox  bool
	Outbox bool
}

func (Relay) Value added in v0.36.0

func (r Relay) Value() string

type RelayList added in v0.36.0

type RelayList = GenericList[Relay]

type System added in v0.36.0

type System struct {
	RelayListCache   cache.Cache32[RelayList]
	FollowListCache  cache.Cache32[FollowList]
	MetadataCache    cache.Cache32[ProfileMetadata]
	Hints            hints.HintsDB
	Pool             *nostr.SimplePool
	RelayListRelays  []string
	FollowListRelays []string
	MetadataRelays   []string
	FallbackRelays   []string
	UserSearchRelays []string
	NoteSearchRelays []string
	Store            eventstore.Store

	StoreRelay nostr.RelayStore
	// contains filtered or unexported fields
}

func NewSystem added in v0.36.0

func NewSystem(mods ...SystemModifier) *System

func (*System) Close added in v0.36.0

func (sys *System) Close()

func (*System) ExpandQueriesByAuthorAndRelays added in v0.36.0

func (sys *System) ExpandQueriesByAuthorAndRelays(
	ctx context.Context,
	filter nostr.Filter,
) (map[string]nostr.Filter, error)

func (*System) FetchFollowList added in v0.36.0

func (sys *System) FetchFollowList(ctx context.Context, pubkey string) FollowList

func (*System) FetchMuteList added in v0.36.0

func (sys *System) FetchMuteList(ctx context.Context, pubkey string) MuteList

func (*System) FetchOutboxRelays added in v0.36.0

func (sys *System) FetchOutboxRelays(ctx context.Context, pubkey string, n int) []string

func (System) FetchProfileFromInput added in v0.36.0

func (sys System) FetchProfileFromInput(ctx context.Context, nip19OrNip05Code string) (ProfileMetadata, error)

FetchProfileFromInput takes an nprofile, npub, nip05 or hex pubkey and returns a ProfileMetadata, updating the hintsDB in the process with any eventual relay hints

func (*System) FetchProfileMetadata added in v0.36.0

func (sys *System) FetchProfileMetadata(ctx context.Context, pubkey string) (pm 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) FetchUserEvents added in v0.36.0

func (sys *System) FetchUserEvents(ctx context.Context, filter nostr.Filter) (map[string][]*nostr.Event, error)

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

func (*System) SearchUsers added in v0.36.0

func (sys *System) SearchUsers(ctx context.Context, query string) []ProfileMetadata

func (*System) TrackEventHints added in v0.37.0

func (sys *System) TrackEventHints(ie nostr.RelayEvent)

type SystemModifier added in v0.36.0

type SystemModifier func(sys *System)

func WithFallbackRelays added in v0.36.0

func WithFallbackRelays(list []string) SystemModifier

func WithFollowListCache added in v0.36.0

func WithFollowListCache(cache cache.Cache32[FollowList]) SystemModifier

func WithFollowListRelays added in v0.36.0

func WithFollowListRelays(list []string) SystemModifier

func WithHintsDB added in v0.36.0

func WithHintsDB(hdb hints.HintsDB) SystemModifier

func WithMetadataCache added in v0.36.0

func WithMetadataCache(cache cache.Cache32[ProfileMetadata]) SystemModifier

func WithMetadataRelays added in v0.36.0

func WithMetadataRelays(list []string) SystemModifier

func WithNoteSearchRelays added in v0.36.0

func WithNoteSearchRelays(list []string) SystemModifier

func WithRelayListCache added in v0.36.0

func WithRelayListCache(cache cache.Cache32[RelayList]) SystemModifier

func WithRelayListRelays added in v0.36.0

func WithRelayListRelays(list []string) SystemModifier

func WithStore added in v0.36.0

func WithStore(store eventstore.Store) SystemModifier

func WithUserSearchRelays added in v0.36.0

func WithUserSearchRelays(list []string) SystemModifier

type TagItemWithValue added in v0.36.0

type TagItemWithValue interface {
	Value() string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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