mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
commit
b211fd35da
@ -748,10 +748,15 @@ func (channel *Channel) applyModeMask(client *Client, mode modes.Mode, op modes.
|
||||
func (channel *Channel) Quit(client *Client) {
|
||||
channel.stateMutex.Lock()
|
||||
channel.members.Remove(client)
|
||||
empty := len(channel.members) == 0
|
||||
channel.stateMutex.Unlock()
|
||||
channel.regenerateMembersCache(false)
|
||||
|
||||
client.removeChannel(channel)
|
||||
|
||||
if empty {
|
||||
client.server.channels.Cleanup(channel)
|
||||
}
|
||||
}
|
||||
|
||||
func (channel *Channel) Kick(client *Client, target *Client, comment string, rb *ResponseBuffer) {
|
||||
|
@ -76,18 +76,20 @@ func (cm *ChannelManager) Join(client *Client, name string, key string, rb *Resp
|
||||
|
||||
entry.channel.Join(client, key, rb)
|
||||
|
||||
cm.maybeCleanup(entry, true)
|
||||
cm.maybeCleanup(entry.channel, true)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cm *ChannelManager) maybeCleanup(entry *channelManagerEntry, afterJoin bool) {
|
||||
func (cm *ChannelManager) maybeCleanup(channel *Channel, afterJoin bool) {
|
||||
cm.Lock()
|
||||
defer cm.Unlock()
|
||||
|
||||
if entry.channel == nil {
|
||||
entry := cm.chans[channel.NameCasefolded()]
|
||||
if entry == nil || entry.channel != channel {
|
||||
return
|
||||
}
|
||||
|
||||
if afterJoin {
|
||||
entry.pendingJoins -= 1
|
||||
}
|
||||
@ -121,10 +123,13 @@ func (cm *ChannelManager) Part(client *Client, name string, message string, rb *
|
||||
return errNoSuchChannel
|
||||
}
|
||||
entry.channel.Part(client, message, rb)
|
||||
cm.maybeCleanup(entry, false)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (cm *ChannelManager) Cleanup(channel *Channel) {
|
||||
cm.maybeCleanup(channel, false)
|
||||
}
|
||||
|
||||
// Rename renames a channel (but does not notify the members)
|
||||
func (cm *ChannelManager) Rename(name string, newname string) error {
|
||||
cfname, err := CasefoldChannel(name)
|
||||
|
Loading…
Reference in New Issue
Block a user