forked from coracle/zooid
Update config
This commit is contained in:
@@ -1,2 +1,4 @@
|
|||||||
bin
|
bin
|
||||||
config
|
config
|
||||||
|
media
|
||||||
|
data
|
||||||
|
|||||||
@@ -33,12 +33,25 @@ Configures NIP 29 support.
|
|||||||
- `auto_join` - whether relay members can join `open` groups without approval. Defaults to `true`.
|
- `auto_join` - whether relay members can join `open` groups without approval. Defaults to `true`.
|
||||||
- `auto_leave` - whether relay members can leave groups without approval. Defaults to `true`.
|
- `auto_leave` - whether relay members can leave groups without approval. Defaults to `true`.
|
||||||
|
|
||||||
|
### `[management]`
|
||||||
|
|
||||||
|
Configures NIP 86 support.
|
||||||
|
|
||||||
|
- `enabled` - whether NIP 86 is enabled.
|
||||||
|
- `methods` - a list of [NIP 86](https://github.com/nostr-protocol/nips/blob/master/86.md) relay management methods enabled for this relay.
|
||||||
|
|
||||||
|
### `[blossom]`
|
||||||
|
|
||||||
|
Configures blossom support.
|
||||||
|
|
||||||
|
- `enabled` - whether blossom is enabled.
|
||||||
|
- `directory` - where to store files. Defaults to `./data/{my-relay}/media`.
|
||||||
|
|
||||||
### `[roles]`
|
### `[roles]`
|
||||||
|
|
||||||
Defines roles that can be assigned to different users and attendant privileges. Each role is defined by a `[roles.{role_name}]` header and has the following options:
|
Defines roles that can be assigned to different users and attendant privileges. Each role is defined by a `[roles.{role_name}]` header and has the following options:
|
||||||
|
|
||||||
- `pubkey` - a list of nostr pubkeys this role is assigned to.
|
- `pubkeys` - a list of nostr pubkeys this role is assigned to.
|
||||||
- `nip86_methods` - a list of [NIP 86](https://github.com/nostr-protocol/nips/blob/master/86.md) relay management methods enabled for this role. Defaults to `[]`.
|
|
||||||
- `can_invite` - a boolean indicating whether this role can invite new members to the relay by requesting a `kind 28935` claim. Defaults to `false`. See [access requests](https://github.com/nostr-protocol/nips/pull/1079) for more details.
|
- `can_invite` - a boolean indicating whether this role can invite new members to the relay by requesting a `kind 28935` claim. Defaults to `false`. See [access requests](https://github.com/nostr-protocol/nips/pull/1079) for more details.
|
||||||
|
|
||||||
A special `[roles.member]` heading may be used to configure policies for all relay users (that is, pubkeys assigned to other roles, or who have redeemed an invite code).
|
A special `[roles.member]` heading may be used to configure policies for all relay users (that is, pubkeys assigned to other roles, or who have redeemed an invite code).
|
||||||
@@ -47,8 +60,7 @@ A special `[roles.member]` heading may be used to configure policies for all rel
|
|||||||
|
|
||||||
Contains information related to data persistence.
|
Contains information related to data persistence.
|
||||||
|
|
||||||
- `sqlite` is the location of the sqlite database file. Defaults to `./data/{my-relay}.db`.
|
- `events` - the location of the sqlite database file used to store events. Defaults to `./data/{my-relay}/events`.
|
||||||
- `media` is the name of the directory for storing blossom files. Defaults to `./media/{my-relay}`.
|
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
||||||
@@ -56,25 +68,28 @@ The below config file might be saved as `./config/my-relay.example.com` in order
|
|||||||
|
|
||||||
```toml
|
```toml
|
||||||
[self]
|
[self]
|
||||||
|
|
||||||
name = "My relay"
|
name = "My relay"
|
||||||
secret = "ce30b1831a4551f4cb7a984033c34ab96d8cf56ff50df9d0c27d9fa5422f2278"
|
secret = "ce30b1831a4551f4cb7a984033c34ab96d8cf56ff50df9d0c27d9fa5422f2278"
|
||||||
|
|
||||||
[roles]
|
[groups]
|
||||||
|
enabled = true
|
||||||
|
auto_join = false
|
||||||
|
|
||||||
|
[management]
|
||||||
|
enabled = true
|
||||||
|
methods = ["supportedmethods", "banpubkey", "allowpubkey"]
|
||||||
|
|
||||||
|
[blossom]
|
||||||
|
enabled = false
|
||||||
|
|
||||||
[roles.member]
|
[roles.member]
|
||||||
|
|
||||||
can_invite = true
|
can_invite = true
|
||||||
|
|
||||||
[roles.admin]
|
[roles.admin]
|
||||||
|
|
||||||
nip86_methods = ["supportedmethods", "banpubkey", "allowpubkey"]
|
|
||||||
pubkeys = ["d9254d9898fd4728f7e2b32b87520221a50f6b8b97d935d7da2de8923988aa6d"]
|
pubkeys = ["d9254d9898fd4728f7e2b32b87520221a50f6b8b97d935d7da2de8923988aa6d"]
|
||||||
|
|
||||||
[groups]
|
[data]
|
||||||
|
events = "./data/my-relay/events"
|
||||||
enabled = true
|
|
||||||
auto_join = false
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package zooid
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fiatjaf.com/nostr/khatru"
|
||||||
|
)
|
||||||
|
|
||||||
|
func EnableBlossom(config *Config, relay *khatru.Relay) {
|
||||||
|
}
|
||||||
+11
-3
@@ -21,15 +21,23 @@ type Config struct {
|
|||||||
AutoLeave bool `toml:"auto_leave"`
|
AutoLeave bool `toml:"auto_leave"`
|
||||||
} `toml:"groups"`
|
} `toml:"groups"`
|
||||||
|
|
||||||
|
Management struct {
|
||||||
|
Enabled bool `toml:"enabled"`
|
||||||
|
Methods []string `toml:"methods"`
|
||||||
|
} `toml:"management"`
|
||||||
|
|
||||||
|
Blossom struct {
|
||||||
|
Enabled bool `toml:"enabled"`
|
||||||
|
Directory string `toml:"directory"`
|
||||||
|
} `toml:"blossom"`
|
||||||
|
|
||||||
Roles map[string]struct {
|
Roles map[string]struct {
|
||||||
Pubkeys []string `toml:"pubkeys"`
|
Pubkeys []string `toml:"pubkeys"`
|
||||||
Nip86Methods []string `toml:"nip86_methods"`
|
|
||||||
CanInvite bool `toml:"can_invite"`
|
CanInvite bool `toml:"can_invite"`
|
||||||
} `toml:"roles"`
|
} `toml:"roles"`
|
||||||
|
|
||||||
Data struct {
|
Data struct {
|
||||||
Sqlite string `toml:"sqlite"`
|
Events string `toml:"events"`
|
||||||
Media string `toml:"media"`
|
|
||||||
} `toml:"data"`
|
} `toml:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package zooid
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fiatjaf.com/nostr/khatru"
|
||||||
|
)
|
||||||
|
|
||||||
|
func EnableGroups(config *Config, relay *khatru.Relay) {
|
||||||
|
relay.Info.SupportedNIPs = append(relay.Info.SupportedNIPs, 29)
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package zooid
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fiatjaf.com/nostr/khatru"
|
||||||
|
)
|
||||||
|
|
||||||
|
func EnableManagement(config *Config, relay *khatru.Relay) {
|
||||||
|
}
|
||||||
+29
-1
@@ -1,12 +1,40 @@
|
|||||||
package zooid
|
package zooid
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fiatjaf.com/nostr/khatru"
|
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"fiatjaf.com/nostr/khatru"
|
||||||
)
|
)
|
||||||
|
|
||||||
func MakeRelay(hostname string, config *Config) *khatru.Relay {
|
func MakeRelay(hostname string, config *Config) *khatru.Relay {
|
||||||
relay := khatru.NewRelay()
|
relay := khatru.NewRelay()
|
||||||
|
relay.Info.Name = config.Name
|
||||||
|
relay.Info.Icon = config.Icon
|
||||||
|
relay.Info.PubKey = config.Pubkey
|
||||||
|
relay.Info.Description = config.Description
|
||||||
|
relay.Info.Self = nostr.GetPublicKey(config.Secret)
|
||||||
|
relay.Info.Software = "https://github.com/coracle-social/zooid"
|
||||||
|
relay.Info.Version = "v0.1.0"
|
||||||
|
|
||||||
|
relay.OnConnect = append(relay.OnConnect, khatru.RequestAuth)
|
||||||
|
relay.RejectFilter = append(relay.RejectFilter, RejectFilter)
|
||||||
|
relay.QueryEvents = append(relay.QueryEvents, QueryEvents)
|
||||||
|
relay.DeleteEvent = append(relay.DeleteEvent, DeleteEvent)
|
||||||
|
relay.RejectEvent = append(relay.RejectEvent, RejectEvent)
|
||||||
|
relay.StoreEvent = append(relay.StoreEvent, SaveEvent)
|
||||||
|
relay.OnEventSaved = append(relay.OnEventSaved, OnEventSaved)
|
||||||
|
|
||||||
|
if config.Groups.Enabled {
|
||||||
|
EnableGroups(config, relay)
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.Blossom.Enabled {
|
||||||
|
EnableBlossom(config, relay)
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.Management.Enabled {
|
||||||
|
EnableManagement(config, relay)
|
||||||
|
}
|
||||||
|
|
||||||
return relay
|
return relay
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user