global

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 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
	Personal  *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
}
View Source
var SupportedKindsDefault = []nostr.Kind{
	0, 1, 3, 5, 6, 7, 8, 9,
	11, 16, 20, 21, 22, 24, 818, 1040,
	1063, 1111, 1222, 1244, 1617, 1618, 1619, 1621,
	1630, 1631, 1632, 1633, 1984, 1985, 7375, 7376,
	9321, 9735, 9802, 10000, 10001, 10002, 10003, 10004,
	10005, 10006, 10007, 10009, 10012, 10015, 10019, 10030, 10050,
	10063, 10101, 10102, 10317, 17375, 24133, 30000, 30002,
	30003, 30004, 30008, 30009, 30015, 30023, 30024, 30030,
	30078, 30311, 30617, 30618, 30818, 30819, 31922, 31923,
	31924, 31925, 39701,
}

this must be sorted, which we do on main()

Functions

func CachePinnedEvent added in v1.0.18

func CachePinnedEvent(relayId RelayID)

func CleanupRelay added in v1.0.20

func CleanupRelay(relay *khatru.Relay)

func End

func End()

func GetAllowedKinds added in v1.0.25

func GetAllowedKinds() []nostr.Kind

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 PreparedPinned added in v1.0.20

func PreparedPinned(pinned *nostr.Event, filter nostr.Filter) (nostr.Event, bool)

if the query allows, we'll wrap the pinned event in a kind:6 repost with "-" tag otherwise we will return it naked. or not return it at all

func PubKeyFromInput added in v1.0.10

func PubKeyFromInput(input string) nostr.PubKey

func QueryStoredWithPinned added in v1.0.18

func QueryStoredWithPinned(relayId RelayID) 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 SaveUserSettings

func SaveUserSettings() error

Types

type RelayID added in v1.0.20

type RelayID string
const (
	RelayMain      RelayID = "main"
	RelayInternal  RelayID = "internal"
	RelayPersonal  RelayID = "personal"
	RelayFavorites RelayID = "favorites"
	RelayGroups    RelayID = "groups"
	RelayInbox     RelayID = "inbox"
	RelaySecret    RelayID = "secret"
	RelayModerated RelayID = "moderated"
	RelayPopular   RelayID = "popular"
	RelayUppermost RelayID = "uppermost"
	RelayBlossom   RelayID = "blossom"
)

func (RelayID) String added in v1.0.20

func (r RelayID) String() string

String returns the string representation of RelayID

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,omitempty"`
	MaxInvitesAtEachLevel   []int  `json:"max_invites_at_each_level,omitempty"`
	MaxEventSize            int    `json:"max_event_size"`
	RequireCurrentTimestamp bool   `json:"require_current_timestamp"`
	EnableOTS               bool   `json:"enable_ots"`
	AcceptScheduledEvents   bool   `json:"accept_scheduled_events"`
	Search                  struct {
		Enable    bool     `json:"enable"`
		Languages []string `json:"languages"`
	} `json:"search"`

	Paywall struct {
		Enabled bool `json:"enable"`
	} `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"`

	Personal struct {
		RelayMetadata
	} `json:"personal"`

	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"`
		RequireAuthForDM    string         `json:"require_auth_for_dm,omitempty"` // "", "always", "when_no_pow"
	} `json:"inbox"`

	Groups struct {
		Enabled                bool   `json:"enabled"`
		EmbeddedLiveKitEnabled bool   `json:"embedded_livekit_enabled"`
		LiveKitServerURL       string `json:"livekit_server_url"`
		LiveKitAPIKey          string `json:"livekit_apikey"`
		LiveKitAPISecret       string `json:"livekit_apisecret"`
	} `json:"groups"`

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

	Blossom struct {
		Enabled                      bool  `json:"enabled"`
		MaxUserUploadSize            int   `json:"max_user_upload_size,omitempty"` // in megabytes, 0 means unlimited
		MaxUserUploadSizeAtEachLevel []int `json:"max_user_upload_size_at_each_level,omitempty"`
	} `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) GetMaxInvitesDisplay added in v1.0.22

func (us UserSettings) GetMaxInvitesDisplay() string

func (UserSettings) GetMaxUserUploadSizeDisplay added in v1.1.0

func (us UserSettings) GetMaxUserUploadSizeDisplay() 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