Send user permissions to client.

We now maintain the user list in the serverConnection.
This commit is contained in:
Juliusz Chroboczek
2021-04-27 18:58:21 +02:00
parent d0ef6a2c0f
commit f0a39fca48
8 changed files with 120 additions and 54 deletions
+14 -9
View File
@@ -106,16 +106,13 @@ func (c *webClient) OverridePermissions(g *group.Group) bool {
return false
}
func (c *webClient) PushClient(id, username string, add bool) error {
kind := "add"
if !add {
kind = "delete"
}
func (c *webClient) PushClient(id, username string, permissions group.ClientPermissions, kind string) error {
return c.write(clientMessage{
Type: "user",
Kind: kind,
Id: id,
Username: username,
Type: "user",
Kind: kind,
Id: id,
Username: username,
Permissions: &permissions,
})
}
@@ -989,6 +986,14 @@ func handleAction(c *webClient, a interface{}) error {
}
}
}
id := c.Id()
user := c.Username()
clients := g.GetClients(nil)
go func(clients []group.Client) {
for _, cc := range clients {
cc.PushClient(id, user, perms, "change")
}
}(clients)
case kickAction:
return group.KickError{
a.id, a.username, a.message,