Commit b20cb0e5 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Simplify the interface to autoLockKick.

This just removes a minor optimisation.
parent bf142c41
...@@ -458,10 +458,9 @@ func add(name string, desc *Description) (*Group, []Client, error) { ...@@ -458,10 +458,9 @@ func add(name string, desc *Description) (*Group, []Client, error) {
g.description = desc g.description = desc
} }
clients := g.getClientsUnlocked(nil) autoLockKick(g)
autoLockKick(g, clients)
return g, clients, nil return g, g.getClientsUnlocked(nil), nil
} }
func Range(f func(g *Group) bool) { func Range(f func(g *Group) bool) {
...@@ -629,11 +628,13 @@ func AddClient(group string, c Client, creds ClientCredentials) (*Group, error) ...@@ -629,11 +628,13 @@ func AddClient(group string, c Client, creds ClientCredentials) (*Group, error)
} }
// called locked // called locked
func autoLockKick(g *Group, clients []Client) { func autoLockKick(g *Group) {
if !(g.description.Autolock && g.locked == nil) && if !(g.description.Autolock && g.locked == nil) &&
!g.description.Autokick { !g.description.Autokick {
return return
} }
clients := g.getClientsUnlocked(nil)
for _, c := range clients { for _, c := range clients {
if member("op", c.Permissions()) { if member("op", c.Permissions()) {
return return
...@@ -642,11 +643,9 @@ func autoLockKick(g *Group, clients []Client) { ...@@ -642,11 +643,9 @@ func autoLockKick(g *Group, clients []Client) {
if g.description.Autolock && g.locked == nil { if g.description.Autolock && g.locked == nil {
m := "this group is locked" m := "this group is locked"
g.locked = &m g.locked = &m
go func(clients []Client) { for _, c := range clients {
for _, c := range clients { c.Joined(g.Name(), "change")
c.Joined(g.Name(), "change") }
}
}(g.getClientsUnlocked(nil))
} }
if g.description.Autokick { if g.description.Autokick {
...@@ -676,7 +675,7 @@ func DelClient(c Client) { ...@@ -676,7 +675,7 @@ func DelClient(c Client) {
g.Name(), "delete", c.Id(), "", nil, nil, g.Name(), "delete", c.Id(), "", nil, nil,
) )
} }
autoLockKick(g, clients) autoLockKick(g)
} }
func (g *Group) GetClients(except Client) []Client { func (g *Group) GetClients(except Client) []Client {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment