Commit 4f531b80 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Implement commands /lock and /unlock.

parent fc6c26e1
......@@ -1214,6 +1214,16 @@ func handleClientMessage(c *client, m clientMessage) error {
if err != nil {
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":
if !c.permissions.Op {
c.error(userError("not authorised"))
......
......@@ -183,6 +183,7 @@ type group struct {
dead bool
description *groupDescription
videoCount uint32
locked uint32
mu sync.Mutex
clients map[string]*client
......@@ -351,6 +352,10 @@ func addClient(name string, client *client, user, pass string) (*group, []userid
}
client.permissions = perms
if !perms.Op && atomic.LoadUint32(&g.locked) != 0 {
return nil, nil, userError("group is locked")
}
g.mu.Lock()
defer g.mu.Unlock()
......
......@@ -867,6 +867,16 @@ function handleInput() {
type: 'clearchat',
});
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 '/unop':
case '/kick':
......
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