mirror of
https://github.com/mumble-voip/grumble.git
synced 2025-12-20 06:10:00 -08:00
Fix various channel freezer bugs.
This commit is contained in:
parent
a42e4d07b4
commit
41689595f2
1 changed files with 77 additions and 47 deletions
36
freeze.go
36
freeze.go
|
|
@ -245,6 +245,7 @@ func (c *Channel) Unfreeze(fc *freezer.Channel) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update ACLs
|
// Update ACLs
|
||||||
|
if fc.Acl != nil {
|
||||||
c.ACL = nil
|
c.ACL = nil
|
||||||
for _, facl := range fc.Acl {
|
for _, facl := range fc.Acl {
|
||||||
acl := NewChannelACL(c)
|
acl := NewChannelACL(c)
|
||||||
|
|
@ -270,8 +271,10 @@ func (c *Channel) Unfreeze(fc *freezer.Channel) {
|
||||||
}
|
}
|
||||||
c.ACL = append(c.ACL, acl)
|
c.ACL = append(c.ACL, acl)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Update groups
|
// Update groups
|
||||||
|
if fc.Groups != nil {
|
||||||
c.Groups = make(map[string]*Group)
|
c.Groups = make(map[string]*Group)
|
||||||
for _, fgrp := range fc.Groups {
|
for _, fgrp := range fc.Groups {
|
||||||
if fgrp.Name == nil {
|
if fgrp.Name == nil {
|
||||||
|
|
@ -292,6 +295,17 @@ func (c *Channel) Unfreeze(fc *freezer.Channel) {
|
||||||
}
|
}
|
||||||
c.Groups[g.Name] = g
|
c.Groups[g.Name] = g
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hook up links, but make them point to the channel itself.
|
||||||
|
// We can't be sure that the channels the links point to exist
|
||||||
|
// yet, so we delay hooking up the map 'correctly' to later.
|
||||||
|
if fc.Links != nil {
|
||||||
|
c.Links = make(map[int]*Channel)
|
||||||
|
for _, link := range fc.Links {
|
||||||
|
c.Links[int(link)] = c
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Freeze a User into a flattened protobuf-based structure
|
// Freeze a User into a flattened protobuf-based structure
|
||||||
|
|
@ -588,8 +602,8 @@ func NewServerFromFrozen(name string) (s *Server, err error) {
|
||||||
|
|
||||||
channelId := int(*fc.Id)
|
channelId := int(*fc.Id)
|
||||||
|
|
||||||
channel, ok := s.Channels[channelId]
|
channel, alreadyExists := s.Channels[channelId]
|
||||||
if !ok {
|
if !alreadyExists {
|
||||||
if fc.Name == nil {
|
if fc.Name == nil {
|
||||||
log.Printf("Skipped Channel creation log entry: No name given.")
|
log.Printf("Skipped Channel creation log entry: No name given.")
|
||||||
continue
|
continue
|
||||||
|
|
@ -610,11 +624,13 @@ func NewServerFromFrozen(name string) (s *Server, err error) {
|
||||||
s.Channels[channelId] = channel
|
s.Channels[channelId] = channel
|
||||||
|
|
||||||
// Mark the channel's parent
|
// Mark the channel's parent
|
||||||
|
if !alreadyExists {
|
||||||
if fc.ParentId != nil {
|
if fc.ParentId != nil {
|
||||||
parents[*fc.Id] = *fc.ParentId
|
parents[*fc.Id] = *fc.ParentId
|
||||||
} else {
|
} else {
|
||||||
delete(parents, *fc.Id)
|
delete(parents, *fc.Id)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
case *freezer.ChannelRemove:
|
case *freezer.ChannelRemove:
|
||||||
fc := val.(*freezer.ChannelRemove)
|
fc := val.(*freezer.ChannelRemove)
|
||||||
|
|
@ -657,6 +673,20 @@ func NewServerFromFrozen(name string) (s *Server, err error) {
|
||||||
parentChan.AddChild(childChan)
|
parentChan.AddChild(childChan)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hook up all channel links
|
||||||
|
for _, channel := range s.Channels {
|
||||||
|
if len(channel.Links) > 0 {
|
||||||
|
links := channel.Links
|
||||||
|
channel.Links = make(map[int]*Channel)
|
||||||
|
for chanId, _ := range links {
|
||||||
|
targetChannel := s.Channels[chanId]
|
||||||
|
if targetChannel != nil {
|
||||||
|
s.LinkChannels(channel, targetChannel)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -717,7 +747,7 @@ func (server *Server) UpdateFrozenChannel(channel *Channel, state *mumbleproto.C
|
||||||
if state.Parent != nil {
|
if state.Parent != nil {
|
||||||
fc.ParentId = state.Parent
|
fc.ParentId = state.Parent
|
||||||
}
|
}
|
||||||
if len(state.LinksAdd) > 0 && len(state.LinksRemove) > 0 {
|
if len(state.LinksAdd) > 0 || len(state.LinksRemove) > 0 {
|
||||||
links := []uint32{}
|
links := []uint32{}
|
||||||
for cid, _ := range channel.Links {
|
for cid, _ := range channel.Links {
|
||||||
links = append(links, uint32(cid))
|
links = append(links, uint32(cid))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue