domain

package
v0.0.0-...-27b9057 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EventKindMetadata               = MustNewEventKind(0)
	EventKindNote                   = MustNewEventKind(1)
	EventKindRecommendedRelay       = MustNewEventKind(2)
	EventKindContacts               = MustNewEventKind(3)
	EventKindEncryptedDirectMessage = MustNewEventKind(4)
	EventKindReaction               = MustNewEventKind(7)
	EventKindRelayListMetadata      = MustNewEventKind(10002)
	// TODO: This should be changed to 30078
	// See https://github.com/nostr-protocol/nips/blob/master/78.md , 6666 is
	// reserved by nip 90
	EventKindRegistration = MustNewEventKind(6666)
)
View Source
var (
	TagProfile = MustNewEventTagName("p")
	TagRelay   = MustNewEventTagName("r")
)
View Source
var ErrNotContactsEvent = errors.New("this is not a contacts event")

Functions

func ShouldReplaceContactsEvent

func ShouldReplaceContactsEvent(old, new Event) (bool, error)

Types

type ContactsExtractor

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

ContactsExtractor does its best to get relay addresses out of events. It should only error out on obvious programming errors but not on malformed user input.

func NewContactsExtractor

func NewContactsExtractor(logger logging.Logger) *ContactsExtractor

func (*ContactsExtractor) Extract

func (e *ContactsExtractor) Extract(event Event) ([]PublicKey, error)

Extract returns ErrNotContactsEvent if the event isn't an event that normally contains contacts. This is to distinguish between events that contain zero contacts and events that don't ever contain contacts.

type Event

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

func NewEvent

func NewEvent(libevent nostr.Event) (Event, error)

func NewEventFromRaw

func NewEventFromRaw(raw []byte) (Event, error)

func NewEventFromUnverifiedEvent

func NewEventFromUnverifiedEvent(event UnverifiedEvent) (Event, error)

func (Event) Content

func (e Event) Content() string

func (Event) CreatedAt

func (e Event) CreatedAt() time.Time

func (Event) HasInvalidProfileTags

func (e Event) HasInvalidProfileTags() bool

func (Event) HasInvalidRTags

func (e Event) HasInvalidRTags() bool

func (Event) Id

func (e Event) Id() EventId

func (Event) IsInvalid

func (e Event) IsInvalid() bool

func (Event) Kind

func (e Event) Kind() EventKind

func (Event) Libevent

func (e Event) Libevent() nostr.Event

func (Event) MarshalJSON

func (e Event) MarshalJSON() ([]byte, error)

func (Event) PubKey

func (e Event) PubKey() PublicKey

func (Event) Raw

func (e Event) Raw() []byte

func (Event) String

func (e Event) String() string

func (Event) Tags

func (e Event) Tags() []EventTag

type EventId

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

func MustNewEventId

func MustNewEventId(s string) EventId

func NewEventIdFromHex

func NewEventIdFromHex(s string) (EventId, error)

func NewEventIdFromNote

func NewEventIdFromNote(s string) (EventId, error)

func (EventId) Bytes

func (id EventId) Bytes() []byte

func (EventId) Hex

func (id EventId) Hex() string

type EventKind

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

func MustNewEventKind

func MustNewEventKind(k int) EventKind

func NewEventKind

func NewEventKind(k int) (EventKind, error)

func (EventKind) Int

func (k EventKind) Int() int

type EventTag

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

func MustNewEventTag

func MustNewEventTag(tag []string) EventTag

func NewEventTag

func NewEventTag(tag []string) (EventTag, error)

func (EventTag) FirstValue

func (e EventTag) FirstValue() string

func (EventTag) FirstValueIsAnEmptyString

func (e EventTag) FirstValueIsAnEmptyString() bool

func (EventTag) IsProfile

func (e EventTag) IsProfile() bool

func (EventTag) IsRelay

func (e EventTag) IsRelay() bool

func (EventTag) Name

func (e EventTag) Name() EventTagName

func (EventTag) Profile

func (e EventTag) Profile() (PublicKey, error)

func (EventTag) Relay

func (e EventTag) Relay() (MaybeRelayAddress, error)

type EventTagName

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

func MustNewEventTagName

func MustNewEventTagName(s string) EventTagName

func NewEventTagName

func NewEventTagName(s string) (EventTagName, error)

func (EventTagName) String

func (e EventTagName) String() string

type Filter

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

func MustNewFilter

func MustNewFilter(
	eventIDs []EventId,
	eventKinds []EventKind,
	eventTags []FilterTag,
	authors []PublicKey,
	since *time.Time,
	until *time.Time,
) Filter

func NewFilter

func NewFilter(
	eventIDs []EventId,
	eventKinds []EventKind,
	eventTags []FilterTag,
	authors []PublicKey,
	since *time.Time,
	until *time.Time,
) (Filter, error)

func (Filter) Libfilter

func (e Filter) Libfilter() nostr.Filter

func (Filter) MarshalJSON

func (e Filter) MarshalJSON() ([]byte, error)

func (Filter) Since

func (f Filter) Since() *time.Time

func (Filter) Until

func (f Filter) Until() *time.Time

type FilterTag

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

func NewFilterTag

func NewFilterTag(name EventTagName, value string) (FilterTag, error)

func (FilterTag) Name

func (f FilterTag) Name() EventTagName

func (FilterTag) Value

func (f FilterTag) Value() string

type MaybeRelayAddress

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

func NewMaybeRelayAddress

func NewMaybeRelayAddress(s string) MaybeRelayAddress

func (MaybeRelayAddress) String

func (a MaybeRelayAddress) String() string

type PublicKey

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

func NewPublicKeyFromHex

func NewPublicKeyFromHex(s string) (PublicKey, error)

func NewPublicKeyFromNpub

func NewPublicKeyFromNpub(s string) (PublicKey, error)

func (PublicKey) Bytes

func (k PublicKey) Bytes() []byte

func (PublicKey) Hex

func (k PublicKey) Hex() string

type PublicKeyToMonitor

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

func MustNewPublicKeyToMonitor

func MustNewPublicKeyToMonitor(publicKey PublicKey, createdAt time.Time, updatedAt time.Time) PublicKeyToMonitor

func NewPublicKeyToMonitor

func NewPublicKeyToMonitor(publicKey PublicKey, createdAt time.Time, updatedAt time.Time) (PublicKeyToMonitor, error)

func (PublicKeyToMonitor) CreatedAt

func (p PublicKeyToMonitor) CreatedAt() time.Time

func (PublicKeyToMonitor) PublicKey

func (p PublicKeyToMonitor) PublicKey() PublicKey

func (PublicKeyToMonitor) UpdatedAt

func (p PublicKeyToMonitor) UpdatedAt() time.Time

type Registration

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

func NewRegistrationFromEvent

func NewRegistrationFromEvent(event Event) (Registration, error)

func (Registration) PublicKey

func (p Registration) PublicKey() PublicKey

func (Registration) Relays

func (p Registration) Relays() []RelayAddress

type RelayAddress

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

func MustNewRelayAddress

func MustNewRelayAddress(s string) RelayAddress

func NewRelayAddress

func NewRelayAddress(s string) (RelayAddress, error)

func NewRelayAddressFromMaybeAddress

func NewRelayAddressFromMaybeAddress(maybe MaybeRelayAddress) (RelayAddress, error)

func (RelayAddress) HostWithoutPort

func (r RelayAddress) HostWithoutPort() string

func (RelayAddress) IsLoopbackOrPrivate

func (r RelayAddress) IsLoopbackOrPrivate() bool

func (RelayAddress) String

func (r RelayAddress) String() string

type RelaysExtractor

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

RelaysExtractor does its best to get relay addresses out of events. It should only error out on obvious programming errors but not on malformed user input.

func NewRelaysExtractor

func NewRelaysExtractor(logger logging.Logger) *RelaysExtractor

func (*RelaysExtractor) Extract

func (e *RelaysExtractor) Extract(event Event) ([]MaybeRelayAddress, error)

type UnverifiedEvent

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

func NewUnverifiedEvent

func NewUnverifiedEvent(libevent nostr.Event) (UnverifiedEvent, error)

func NewUnverifiedEventFromRaw

func NewUnverifiedEventFromRaw(raw []byte) (UnverifiedEvent, error)

func (UnverifiedEvent) CreatedAt

func (u UnverifiedEvent) CreatedAt() time.Time

func (UnverifiedEvent) HasInvalidProfileTags

func (u UnverifiedEvent) HasInvalidProfileTags() bool

func (UnverifiedEvent) HasInvalidRTags

func (u UnverifiedEvent) HasInvalidRTags() bool

func (UnverifiedEvent) Id

func (u UnverifiedEvent) Id() EventId

func (UnverifiedEvent) IsInvalid

func (u UnverifiedEvent) IsInvalid() bool

func (UnverifiedEvent) Kind

func (u UnverifiedEvent) Kind() EventKind

func (UnverifiedEvent) PubKey

func (u UnverifiedEvent) PubKey() PublicKey

func (UnverifiedEvent) Raw

func (u UnverifiedEvent) Raw() []byte

func (UnverifiedEvent) String

func (u UnverifiedEvent) String() string

func (UnverifiedEvent) Tags

func (u UnverifiedEvent) Tags() []EventTag

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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