event

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KindProfileMetadata             int = 0
	KindTextNote                    int = 1
	KindRecommendServer             int = 2
	KindContactList                 int = 3
	KindEncryptedDirectMessage      int = 4
	KindDeletion                    int = 5
	KindRepost                      int = 6
	KindReaction                    int = 7
	KindSimpleGroupChatMessage      int = 9
	KindSimpleGroupThread           int = 11
	KindSimpleGroupReply            int = 12
	KindChannelCreation             int = 40
	KindChannelMetadata             int = 41
	KindChannelMessage              int = 42
	KindChannelHideMessage          int = 43
	KindChannelMuteUser             int = 44
	KindPatch                       int = 1617
	KindFileMetadata                int = 1063
	KindSimpleGroupAddUser          int = 9000
	KindSimpleGroupRemoveUser       int = 9001
	KindSimpleGroupEditMetadata     int = 9002
	KindSimpleGroupAddPermission    int = 9003
	KindSimpleGroupRemovePermission int = 9004
	KindSimpleGroupDeleteEvent      int = 9005
	KindSimpleGroupEditGroupStatus  int = 9006
	KindSimpleGroupJoinRequest      int = 9021
	KindZapRequest                  int = 9734
	KindZap                         int = 9735
	KindMuteList                    int = 10000
	KindPinList                     int = 10001
	KindRelayListMetadata           int = 10002
	KindNWCWalletInfo               int = 13194
	KindClientAuthentication        int = 22242
	KindNWCWalletRequest            int = 23194
	KindNWCWalletResponse           int = 23195
	KindNostrConnect                int = 24133
	KindCategorizedPeopleList       int = 30000
	KindCategorizedBookmarksList    int = 30001
	KindProfileBadges               int = 30008
	KindBadgeDefinition             int = 30009
	KindStallDefinition             int = 30017
	KindProductDefinition           int = 30018
	KindArticle                     int = 30023
	KindApplicationSpecificData     int = 30078
	KindRepositoryAnnouncement      int = 30617
	KindSimpleGroupMetadata         int = 39000
	KindSimpleGroupAdmins           int = 39001
	KindSimpleGroupMembers          int = 39002
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Kind      int       `json:"kind"`
	Content   string    `json:"content"`
	Tags      Tags      `json:"tags"`
	CreatedAt Timestamp `json:"created_at"`
	ID        *string   `json:"id"`     // set by Sign()
	Pubkey    *string   `json:"pubkey"` // set by Sign()
	Sig       *string   `json:"sig"`    // set by Sign()
}

func NewEvent

func NewEvent(kind int, content string, tags Tags, createdAt *int64, id *string, pubkey *string, sig *string) *Event

func (Event) MarshalEasyJSON

func (v Event) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Event) MarshalJSON

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

MarshalJSON supports json.Marshaler interface

func (Event) Serialize

func (e Event) Serialize() []byte

Serialize outputs a []byte JSON array of the Event

func (*Event) Sign

func (e *Event) Sign(privateKey string, signOpts ...schnorr.SignOption) error

Sign signs an event with the given privateKey

func (Event) String

func (e Event) String() string

String implements Stringer interface, returns raw JSON as a string.

func (*Event) UnmarshalEasyJSON

func (v *Event) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Event) UnmarshalJSON

func (v *Event) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

func (Event) Validate

func (e Event) Validate() error

func (Event) ValidateSignature

func (e Event) ValidateSignature() (bool, error)

ValidateSignature checks if the signature is valid for the id.

type Eventer

type Eventer interface {
	Serialize() []byte
	Sign(privateKey string, signOpts ...schnorr.SignOption) error
	String() string
	Validate() error
	ValidateSignature() (bool, error)
}

Eventer TODO what's a better name?

type Tag

type Tag []string

type Tags

type Tags []Tag

type Timestamp

type Timestamp int64

func NewTimestamp added in v0.0.7

func NewTimestamp(t time.Time) Timestamp

func Now

func Now() Timestamp

func (Timestamp) Time

func (t Timestamp) Time() time.Time

Jump to

Keyboard shortcuts

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