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:
Ola Bini 2020-07-03 17:39:49 +00:00
parent ebe189c524
commit dd4cf8748f
No known key found for this signature in database
GPG key ID: 6786A150F6A2B28F

View file

@ -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)),