mirror of
https://github.com/github-tijlxyz/khatru-pyramid.git
synced 2025-04-19 18:31:18 +00:00
add userdata path to envconfig and expand example.env
This commit is contained in:
parent
ac6ae108e7
commit
b6ebdb9e5b
20
example.env
20
example.env
@ -1,5 +1,17 @@
|
||||
RELAY_NAME="Name of the Relay"
|
||||
RELAY_DESCRIPTION="Description of the relay"
|
||||
RELAY_PUBKEY="07adfda9c5adc80881bb2a5220f6e3181e0c043b90fa115c4f183464022968e6"
|
||||
RELAY_CONTACT="email@example.com"
|
||||
|
||||
# Server Settings
|
||||
DOMAIN="example.com"
|
||||
PORT="3334" # optional
|
||||
DATABASE_PATH="./db" # optional
|
||||
USERDATA_PATH="./users.json" # optional
|
||||
|
||||
# Hierarchy Settings
|
||||
MAX_INVITES_PER_PERSON="3" # optional
|
||||
|
||||
# Relay Settings
|
||||
RELAY_NAME="Name of the Relay"
|
||||
RELAY_PUBKEY="07adfda9c5adc80881bb2a5220f6e3181e0c043b90fa115c4f183464022968e6"
|
||||
RELAY_DESCRIPTION="Description of the relay" # optional
|
||||
RELAY_CONTACT="email@example.com" # optional
|
||||
RELAY_ICON="https://example.com/icon.png" # optional
|
||||
|
||||
|
1
main.go
1
main.go
@ -28,6 +28,7 @@ type Settings struct {
|
||||
RelayContact string `envconfig:"RELAY_CONTACT"`
|
||||
RelayIcon string `envconfig:"RELAY_ICON"`
|
||||
DatabasePath string `envconfig:"DATABASE_PATH" default:"./db"`
|
||||
UserdataPath string `envconfig:"USERDATA_PATH" default:"./users.json"`
|
||||
|
||||
MaxInvitesPerPerson int `envconfig:"MAX_INVITES_PER_PERSON" default:"3"`
|
||||
}
|
||||
|
@ -8,8 +8,6 @@ import (
|
||||
"github.com/nbd-wtf/go-nostr"
|
||||
)
|
||||
|
||||
const WHITELIST_FILE = "users.json"
|
||||
|
||||
type Whitelist map[string]string // { [user_pubkey]: [invited_by] }
|
||||
|
||||
func addToWhitelist(pubkey string, inviter string) error {
|
||||
@ -89,7 +87,7 @@ func removeDescendantsFromWhitelist(ancestor string) {
|
||||
}
|
||||
|
||||
func loadWhitelist() error {
|
||||
b, err := os.ReadFile(WHITELIST_FILE)
|
||||
b, err := os.ReadFile(s.UserdataPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -107,7 +105,7 @@ func saveWhitelist() error {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := os.WriteFile(WHITELIST_FILE, jsonBytes, 0644); err != nil {
|
||||
if err := os.WriteFile(s.UserdataPath, jsonBytes, 0644); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user