mirror of
https://github.com/mumble-voip/grumble.git
synced 2025-12-19 21:59:59 -08:00
For now, do a slow calculation of all permissions for a specific channel and client. This is necessary for features in the client UI to work well - including the chat box
This commit is contained in:
parent
ebe189c524
commit
dd4cf8748f
1 changed files with 32 additions and 8 deletions
|
|
@ -907,17 +907,41 @@ func (server *Server) sendUserList(client *Client) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send a client its permissions for channel.
|
var allPermissions = []acl.Permission{
|
||||||
func (server *Server) sendClientPermissions(client *Client, channel *Channel) {
|
acl.WritePermission,
|
||||||
// No caching for SuperUser
|
acl.TraversePermission,
|
||||||
if client.IsSuperUser() {
|
acl.EnterPermission,
|
||||||
return
|
acl.SpeakPermission,
|
||||||
|
acl.MuteDeafenPermission,
|
||||||
|
acl.MovePermission,
|
||||||
|
acl.MakeChannelPermission,
|
||||||
|
acl.LinkChannelPermission,
|
||||||
|
acl.WhisperPermission,
|
||||||
|
acl.TextMessagePermission,
|
||||||
|
acl.TempChannelPermission,
|
||||||
|
acl.KickPermission,
|
||||||
|
acl.BanPermission,
|
||||||
|
acl.RegisterPermission,
|
||||||
|
acl.SelfRegisterPermission,
|
||||||
|
}
|
||||||
|
|
||||||
|
// calculateChannelPermissionsForClient checks what permissions a specific client has for the channel
|
||||||
|
// it doesn't do this in a very nice way right now, but it should work.
|
||||||
|
func calculateChannelPermissionsForClient(client *Client, channel *Channel) acl.Permission {
|
||||||
|
result := acl.Permission(acl.NonePermission)
|
||||||
|
|
||||||
|
for _, p := range allPermissions {
|
||||||
|
if acl.HasPermission(&channel.ACL, client, p) {
|
||||||
|
result = result | p
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// fixme(mkrautz): re-add when we have ACL caching
|
return result
|
||||||
return
|
}
|
||||||
|
|
||||||
perm := acl.Permission(acl.NonePermission)
|
// Send a client its permissions for channel.
|
||||||
|
func (server *Server) sendClientPermissions(client *Client, channel *Channel) {
|
||||||
|
perm := calculateChannelPermissionsForClient(client, channel)
|
||||||
client.sendMessage(&mumbleproto.PermissionQuery{
|
client.sendMessage(&mumbleproto.PermissionQuery{
|
||||||
ChannelId: proto.Uint32(uint32(channel.Id)),
|
ChannelId: proto.Uint32(uint32(channel.Id)),
|
||||||
Permissions: proto.Uint32(uint32(perm)),
|
Permissions: proto.Uint32(uint32(perm)),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue