1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-09 18:25:58 +01:00

Simplify the interface to autoLockKick.

This just removes a minor optimisation.
This commit is contained in:
Juliusz Chroboczek 2022-09-22 17:21:49 +02:00
parent bf142c41a0
commit b20cb0e523

View file

@ -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)
} }
// 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) {
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) {
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 {