Add handlers
This commit is contained in:
+17
-3
@@ -15,7 +15,7 @@ type Role struct {
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
Host string
|
||||
Host string
|
||||
Self struct {
|
||||
Name string `toml:"name"`
|
||||
Icon string `toml:"icon"`
|
||||
@@ -25,6 +25,10 @@ type Config struct {
|
||||
Description string `toml:"description"`
|
||||
} `toml:"self"`
|
||||
|
||||
Policy struct {
|
||||
StripSignatures bool `toml:"strip_signatures"`
|
||||
} `toml:"policy"`
|
||||
|
||||
Groups struct {
|
||||
Enabled bool `toml:"enabled"`
|
||||
AutoJoin bool `toml:"auto_join"`
|
||||
@@ -79,8 +83,8 @@ func (config *Config) GetRolesForPubkey(pubkey nostr.PubKey) []Role {
|
||||
return roles
|
||||
}
|
||||
|
||||
func (config *Config) CanManage(roles []Role) bool {
|
||||
for _, role := range roles {
|
||||
func (config *Config) CanManage(pubkey nostr.PubKey) bool {
|
||||
for _, role := range config.GetRolesForPubkey(pubkey) {
|
||||
if role.CanManage {
|
||||
return true
|
||||
}
|
||||
@@ -88,3 +92,13 @@ func (config *Config) CanManage(roles []Role) bool {
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (config *Config) CanInvite(pubkey nostr.PubKey) bool {
|
||||
for _, role := range config.GetRolesForPubkey(pubkey) {
|
||||
if role.CanInvite {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user