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.
|
||||
func (server *Server) sendClientPermissions(client *Client, channel *Channel) {
|
||||
// No caching for SuperUser
|
||||
if client.IsSuperUser() {
|
||||
return
|
||||
var allPermissions = []acl.Permission{
|
||||
acl.WritePermission,
|
||||
acl.TraversePermission,
|
||||
acl.EnterPermission,
|
||||
acl.SpeakPermission,
|
||||
acl.MuteDeafenPermission,
|
||||
acl.MovePermission,
|
||||
acl.MakeChannelPermission,
|
||||
acl.LinkChannelPermission,
|
||||
acl.WhisperPermission,
|
||||
acl.TextMessagePermission,
|
||||
acl.TempChannelPermission,
|
||||
acl.KickPermission,
|
||||
acl.BanPermission,
|
||||
acl.RegisterPermission,
|
||||
acl.SelfRegisterPermission,
|
||||
}
|
||||
|
||||
// fixme(mkrautz): re-add when we have ACL caching
|
||||
return
|
||||
// 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)
|
||||
|
||||
perm := acl.Permission(acl.NonePermission)
|
||||
for _, p := range allPermissions {
|
||||
if acl.HasPermission(&channel.ACL, client, p) {
|
||||
result = result | p
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// Send a client its permissions for channel.
|
||||
func (server *Server) sendClientPermissions(client *Client, channel *Channel) {
|
||||
perm := calculateChannelPermissionsForClient(client, channel)
|
||||
client.sendMessage(&mumbleproto.PermissionQuery{
|
||||
ChannelId: proto.Uint32(uint32(channel.Id)),
|
||||
Permissions: proto.Uint32(uint32(perm)),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue