mirror of
https://github.com/jech/galene.git
synced 2024-11-09 18:25:58 +01:00
Tweak the autokick code.
This commit is contained in:
parent
c769a4aad4
commit
a15915e8fc
2 changed files with 26 additions and 23 deletions
3
README
3
README
|
@ -243,7 +243,8 @@ the group.
|
|||
- `autolock`: if true, the group will start locked and become locked
|
||||
whenever there are no clients with operator privileges;
|
||||
- `autokick`: if true, all clients will be kicked out whenever there are
|
||||
no clients with operator privileges.
|
||||
no clients with operator privileges; this is not recommended, prefer
|
||||
the `autolock` option instead;
|
||||
- `redirect`: if set, then attempts to join the group will be redirected
|
||||
to the given URL; most other fields are ignored in this case;
|
||||
- `codecs`: this is a list of codecs allowed in this group. The default
|
||||
|
|
|
@ -438,6 +438,8 @@ func AddClient(group string, c Client) (*Group, error) {
|
|||
g.mu.Lock()
|
||||
defer g.mu.Unlock()
|
||||
|
||||
clients := g.getClientsUnlocked(nil)
|
||||
|
||||
if !c.OverridePermissions(g) {
|
||||
perms, err := g.description.GetPermission(group, c)
|
||||
if err != nil {
|
||||
|
@ -446,28 +448,15 @@ func AddClient(group string, c Client) (*Group, error) {
|
|||
|
||||
c.SetPermissions(perms)
|
||||
|
||||
if !perms.Op && g.locked != nil {
|
||||
if !perms.Op {
|
||||
if g.locked != nil {
|
||||
m := *g.locked
|
||||
if m == "" {
|
||||
m = "this group is locked"
|
||||
}
|
||||
return nil, UserError(m)
|
||||
}
|
||||
|
||||
if !perms.Op && g.description.MaxClients > 0 {
|
||||
if len(g.clients) >= g.description.MaxClients {
|
||||
return nil, UserError("too many users")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
clients := g.getClientsUnlocked(nil)
|
||||
|
||||
if g.clients[c.Id()] != nil {
|
||||
return nil, ProtocolError("duplicate client id")
|
||||
}
|
||||
|
||||
if !c.Permissions().Op && g.description.Autokick {
|
||||
if g.description.Autokick {
|
||||
ops := false
|
||||
for _, c := range clients {
|
||||
if c.Permissions().Op {
|
||||
|
@ -477,10 +466,23 @@ func AddClient(group string, c Client) (*Group, error) {
|
|||
}
|
||||
if !ops {
|
||||
return nil, UserError(
|
||||
"there are no operators in this group",
|
||||
"there are no operators " +
|
||||
"in this group",
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !perms.Op && g.description.MaxClients > 0 {
|
||||
if len(g.clients) >= g.description.MaxClients {
|
||||
return nil, UserError("too many users")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if g.clients[c.Id()] != nil {
|
||||
return nil, ProtocolError("duplicate client id")
|
||||
}
|
||||
|
||||
g.clients[c.Id()] = c
|
||||
g.timestamp = time.Now()
|
||||
|
|
Loading…
Reference in a new issue