Implement message permission and shutup command.

This commit is contained in:
Juliusz Chroboczek
2024-05-08 16:00:18 +02:00
parent 2b145317a5
commit 1315084185
9 changed files with 85 additions and 38 deletions
+15
View File
@@ -106,6 +106,15 @@ func (token *Stateful) Check(host, group string, username *string) (string, []st
return user, token.Permissions, nil
}
func member(v string, l []string) bool {
for _, w := range l {
if v == w {
return true
}
}
return false
}
// load updates the state from the corresponding file.
// called locked
func (state *state) load() (string, error) {
@@ -155,6 +164,12 @@ func (state *state) load() (string, error) {
state.fileSize = 0
return "", err
}
// the "message" permission was introduced in Galene 0.9,
// so add it to tokens read from disk. We can remove this
// hack in late 2024.
if !member("message", t.Permissions) {
t.Permissions = append(t.Permissions, "message")
}
ts[t.Token] = &t
}
state.tokens = ts