mirror of
https://github.com/jech/galene.git
synced 2024-11-22 16:45:58 +01:00
Implement commands /lock and /unlock.
This commit is contained in:
parent
037f002a29
commit
12858e1f36
3 changed files with 25 additions and 0 deletions
10
client.go
10
client.go
|
@ -1248,6 +1248,16 @@ func handleClientMessage(c *client, m clientMessage) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.error(err)
|
return c.error(err)
|
||||||
}
|
}
|
||||||
|
case "lock", "unlock":
|
||||||
|
if !c.permissions.Op {
|
||||||
|
c.error(userError("not authorised"))
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
var locked uint32
|
||||||
|
if m.Type == "lock" {
|
||||||
|
locked = 1
|
||||||
|
}
|
||||||
|
atomic.StoreUint32(&c.group.locked, locked)
|
||||||
case "kick":
|
case "kick":
|
||||||
if !c.permissions.Op {
|
if !c.permissions.Op {
|
||||||
c.error(userError("not authorised"))
|
c.error(userError("not authorised"))
|
||||||
|
|
5
group.go
5
group.go
|
@ -199,6 +199,7 @@ type group struct {
|
||||||
dead bool
|
dead bool
|
||||||
description *groupDescription
|
description *groupDescription
|
||||||
videoCount uint32
|
videoCount uint32
|
||||||
|
locked uint32
|
||||||
|
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
clients map[string]*client
|
clients map[string]*client
|
||||||
|
@ -366,6 +367,10 @@ func addClient(name string, client *client, user, pass string) (*group, []userid
|
||||||
}
|
}
|
||||||
client.permissions = perms
|
client.permissions = perms
|
||||||
|
|
||||||
|
if !perms.Op && atomic.LoadUint32(&g.locked) != 0 {
|
||||||
|
return nil, nil, userError("group is locked")
|
||||||
|
}
|
||||||
|
|
||||||
g.mu.Lock()
|
g.mu.Lock()
|
||||||
defer g.mu.Unlock()
|
defer g.mu.Unlock()
|
||||||
|
|
||||||
|
|
|
@ -888,6 +888,16 @@ function handleInput() {
|
||||||
type: 'clearchat',
|
type: 'clearchat',
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
case '/lock':
|
||||||
|
case '/unlock':
|
||||||
|
if(!permissions.op) {
|
||||||
|
displayError("You're not an operator");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
send({
|
||||||
|
type: cmd === '/lock' ? 'lock' : 'unlock',
|
||||||
|
});
|
||||||
|
return;
|
||||||
case '/op':
|
case '/op':
|
||||||
case '/unop':
|
case '/unop':
|
||||||
case '/kick':
|
case '/kick':
|
||||||
|
|
Loading…
Reference in a new issue