Fix race condition with NICK and QUIT when multiple dispatch users are in the same channel

This commit is contained in:
Ken-Håvard Lieng 2017-04-11 03:49:52 +02:00
parent 3393b1b706
commit 18651c1a10
8 changed files with 145 additions and 138 deletions

View file

@ -57,10 +57,9 @@ func (i *ircHandler) dispatchMessage(msg *irc.Message) {
func (i *ircHandler) nick(msg *irc.Message) {
i.session.sendJSON("nick", Nick{
Server: i.client.Host,
Old: msg.Nick,
New: msg.LastParam(),
Channels: channelStore.FindUserChannels(msg.Nick, i.client.Host),
Server: i.client.Host,
Old: msg.Nick,
New: msg.LastParam(),
})
channelStore.RenameUser(msg.Nick, msg.LastParam(), i.client.Host)
@ -138,10 +137,9 @@ func (i *ircHandler) message(msg *irc.Message) {
func (i *ircHandler) quit(msg *irc.Message) {
i.session.sendJSON("quit", Quit{
Server: i.client.Host,
User: msg.Nick,
Reason: msg.LastParam(),
Channels: channelStore.FindUserChannels(msg.Nick, i.client.Host),
Server: i.client.Host,
User: msg.Nick,
Reason: msg.LastParam(),
})
channelStore.RemoveUserAll(msg.Nick, i.client.Host)

View file

@ -27,10 +27,9 @@ type Connect struct {
}
type Nick struct {
Server string `json:"server"`
Old string `json:"old"`
New string `json:"new"`
Channels []string `json:"channels"`
Server string `json:"server"`
Old string `json:"old"`
New string `json:"new"`
}
type Join struct {
@ -56,10 +55,9 @@ type Mode struct {
}
type Quit struct {
Server string `json:"server"`
User string `json:"user"`
Reason string `json:"reason,omitempty"`
Channels []string `json:"channels"`
Server string `json:"server"`
User string `json:"user"`
Reason string `json:"reason,omitempty"`
}
type Chat struct {