sdk

package
v1.2.7 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: GPL-2.0, MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InputToEventPointer

func InputToEventPointer(input string) (ep *pointers.Event)

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

func InputToProfile

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

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

func IsValidRelayURL

func IsValidRelayURL(u string) bool

Types

type Follow

type Follow struct {
	Pubkey  string
	Relay   string
	Petname string
}

Follow is a nostr account that a user is following

type ProfileMetadata

type ProfileMetadata struct {
	// PubKey must always be set otherwise things will break
	PubKey string `json:"-"`
	// Event may be empty if a profile metadata event wasn't found
	Event *event.T `json:"-,omitempty"`
	// 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 *pool.Simple,
	pubkey string, relays ...string) (pm *ProfileMetadata)

func ParseMetadata

func ParseMetadata(ev *event.T) (pm *ProfileMetadata, err error)

func (ProfileMetadata) Nprofile

func (p ProfileMetadata) Nprofile(c context.T, sys *System, nr 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.Profile
	Event   *pointers.Event
	Entity  *pointers.Entity
}

func ParseReferences

func ParseReferences(evt *event.T) (refs []*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 *pool.Simple, pubkey string, relays ...string) (r []Relay)

func ParseRelaysFromKind10002

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

func ParseRelaysFromKind3

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

type System

type System struct {
	RelaysCache      cache32.I[[]Relay]
	FollowsCache     cache32.I[[]Follow]
	MetadataCache    cache32.I[*ProfileMetadata]
	Pool             *pool.Simple
	RelayListRelays  []string
	FollowListRelays []string
	MetadataRelays   []string
	Store            eventstore.Store
}

func (*System) ExpandQueriesByAuthorAndRelays

func (s *System) ExpandQueriesByAuthorAndRelays(
	c context.T,
	f *filter.T,
) (filters map[*client.T]*filter.T, err error)

func (*System) FetchOrStoreProfileMetadata

func (s *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 (s *System) FetchOutboxRelays(c context.T, pubkey string) []string

func (*System) FetchProfileMetadata

func (s *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 (s *System) FetchRelays(c context.T, pubkey string) []Relay

func (*System) FetchUserEvents

func (s *System) FetchUserEvents(c context.T,
	f *filter.T) (r map[string][]*event.T, err error)

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

func (*System) StoreRelay

func (s *System) StoreRelay() eventstore.RelayInterface

Directories

Path Synopsis
cache

Jump to

Keyboard shortcuts

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