global

package
v1.0.19 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: Unlicense Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	S struct {
		Port     string `envconfig:"PORT" default:"3334"`
		SFTPPort string `envconvig:"SFTP_PORT" default:"2222"`
		Host     string `envconfig:"HOST" default:"localhost"`
		DataPath string `envconfig:"DATA_PATH" default:"./data"`
	}
	Nostr    *sdk.System
	MMMM     *mmm.MultiMmapManager
	Settings UserSettings
)
View Source
var FiveSecondsDebouncer = debounce.New(time.Second * 5)
View Source
var IL struct {
	// for usage with the sdk
	System *mmm.IndexingLayer

	// main relay
	Main *mmm.IndexingLayer

	// specific
	Favorites *mmm.IndexingLayer
	Internal  *mmm.IndexingLayer
	Groups    *mmm.IndexingLayer
	Inbox     *mmm.IndexingLayer

	// only nip44-encrypted DMs for now
	Secret *mmm.IndexingLayer

	// moderated relay
	ModerationQueue *mmm.IndexingLayer
	Moderated       *mmm.IndexingLayer

	// algo
	Popular   *mmm.IndexingLayer
	Uppermost *mmm.IndexingLayer

	// scheduled events
	Scheduled *mmm.IndexingLayer

	// blossom blob index
	Blossom *mmm.IndexingLayer
}
View Source
var Log = zerolog.New(os.Stderr).Output(zerolog.ConsoleWriter{Out: os.Stdout}).With().Timestamp().Logger()
View Source
var PinnedCache struct {
	Main      *nostr.Event
	Internal  *nostr.Event
	Favorites *nostr.Event
	Popular   *nostr.Event
	Uppermost *nostr.Event
	Moderated *nostr.Event
}

Functions

func CachePinnedEvent added in v1.0.18

func CachePinnedEvent(relayId string)

func CanReadPaywalled

func CanReadPaywalled(author, reader nostr.PubKey) bool

returns a cached boolean or computes it and returns

func End

func End()

func GetLoggedUser

func GetLoggedUser(r *http.Request) (nostr.PubKey, bool)

func Init

func Init() error

func JSONString added in v1.0.18

func JSONString(v any) string

func PubKeyFromInput added in v1.0.10

func PubKeyFromInput(input string) nostr.PubKey

func QueryStoredWithPinned added in v1.0.18

func QueryStoredWithPinned(relayId string) func(ctx context.Context, filter nostr.Filter) iter.Seq[nostr.Event]

QueryStoredWithPinned is a custom QueryStored function that returns pinned events first when that makes sense

func ResetPaywallCache

func ResetPaywallCache(receiver, payer nostr.PubKey)

func SaveUserSettings

func SaveUserSettings() error

Types

type RelayMetadata added in v1.0.1

type RelayMetadata struct {
	Enabled      bool     `json:"enabled"`
	Name         string   `json:"name"`
	Description  string   `json:"description"`
	Icon         string   `json:"icon"`
	HTTPBasePath string   `json:"path"`
	Pinned       nostr.ID `json:"pinned,omitempty"`
	// contains filtered or unexported fields
}

func (RelayMetadata) GetDescription added in v1.0.1

func (rm RelayMetadata) GetDescription() string

func (RelayMetadata) GetIcon added in v1.0.1

func (rm RelayMetadata) GetIcon() string

func (RelayMetadata) GetName added in v1.0.1

func (rm RelayMetadata) GetName() string

func (RelayMetadata) IsIconDefault added in v1.0.1

func (rm RelayMetadata) IsIconDefault() bool

func (RelayMetadata) IsNameDefault added in v1.0.1

func (rm RelayMetadata) IsNameDefault() bool

type UserSettings

type UserSettings struct {
	// relay metadata
	Domain           string   `json:"domain"`
	RelayName        string   `json:"relay_name"`
	RelayDescription string   `json:"relay_description"`
	RelayContact     string   `json:"relay_contact"`
	RelayIcon        string   `json:"relay_icon"`
	Pinned           nostr.ID `json:"pinned,omitempty"`

	// theme
	Theme struct {
		BackgroundColor          string `json:"background_color"`
		TextColor                string `json:"text_color"`
		AccentColor              string `json:"accent_color"`
		SecondaryBackgroundColor string `json:"secondary_background_color"`
		ExtraColor               string `json:"extra_color"`
		BaseColor                string `json:"base_color"`
		HeaderTransparency       string `json:"header_transparency"`
		PrimaryFont              string `json:"primary_font"`
		SecondaryFont            string `json:"secondary_font"`
	} `json:"theme"`

	// general
	BrowseURI               string `json:"browse_uri"`
	LinkURL                 string `json:"link_url"`
	MaxInvitesPerPerson     int    `json:"max_invites_per_person"`
	MaxEventSize            int    `json:"max_event_size"`
	RequireCurrentTimestamp bool   `json:"require_current_timestamp"`
	EnableOTS               bool   `json:"enable_ots"`
	AcceptScheduledEvents   bool   `json:"accept_scheduled_events"`

	Paywall struct {
		Tag        string `json:"tag"`
		AmountSats uint   `json:"amount_sats"`
		PeriodDays uint   `json:"period_days"`
	} `json:"paywall"`

	NIP05 struct {
		Enabled bool                    `json:"enabled"`
		Names   map[string]nostr.PubKey `json:"names"`
	} `json:"nip05"`

	RelayInternalSecretKey nostr.SecretKey `json:"relay_internal_secret_key"`

	BlockedIPs   []string     `json:"blocked_ips"`
	AllowedKinds []nostr.Kind `json:"allowed_kinds,omitempty"`

	// per-relay
	Internal struct {
		RelayMetadata
	} `json:"internal"`

	Favorites struct {
		RelayMetadata
	} `json:"favorites"`

	Inbox struct {
		RelayMetadata
		SpecificallyBlocked []nostr.PubKey `json:"specifically_blocked"`
		HellthreadLimit     int            `json:"hellthread_limit"`
		MinDMPoW            int            `json:"min_dm_pow"`
	} `json:"inbox"`

	Groups struct {
		Enabled bool `json:"enabled"`
	} `json:"groups"`

	Grasp struct {
		Enabled bool `json:"enabled"`
	} `json:"grasp"`

	Blossom struct {
		Enabled bool `json:"enabled"`
	} `json:"blossom"`

	Popular struct {
		RelayMetadata
		PercentThreshold int `json:"percent_threshold"`
	} `json:"popular"`

	Uppermost struct {
		RelayMetadata
		PercentThreshold int `json:"percent_threshold"`
	} `json:"uppermost"`

	Moderated struct {
		RelayMetadata
		MinPoW uint `json:"min_pow"`
	} `json:"moderated"`

	FTP struct {
		Enabled  bool   `json:"enabled"`
		Password string `json:"password"`
	} `json:"ftp"`
}
func (us UserSettings) GetExternalLink(pointer nostr.Pointer) string

func (UserSettings) HTTPScheme

func (us UserSettings) HTTPScheme() string

func (UserSettings) HasThemeColors

func (us UserSettings) HasThemeColors() bool

func (UserSettings) WSScheme

func (us UserSettings) WSScheme() string

Jump to

Keyboard shortcuts

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