Fix handling of PART messages with no reason
This commit is contained in:
parent
52f929ec45
commit
50dc0ef64f
File diff suppressed because one or more lines are too long
@ -85,8 +85,7 @@ export default createReducer(Map(), {
|
||||
},
|
||||
|
||||
[actions.SOCKET_PART](state, action) {
|
||||
const { server, channels, user } = action;
|
||||
const channel = channels[0];
|
||||
const { server, channel, user } = action;
|
||||
if (state.hasIn([server, channel])) {
|
||||
return state.updateIn([server, channel, 'users'], users =>
|
||||
users.filter(u => u.nick !== user)
|
||||
|
@ -45,8 +45,8 @@ export default function handleSocket(socket, { dispatch, getState }) {
|
||||
dispatch(inform(`${user} joined the channel`, server, channels[0]))
|
||||
);
|
||||
|
||||
socket.on('part', ({ user, server, channels, reason }) =>
|
||||
dispatch(inform(withReason(`${user} left the channel`, reason), server, channels[0]))
|
||||
socket.on('part', ({ user, server, channel, reason }) =>
|
||||
dispatch(inform(withReason(`${user} left the channel`, reason), server, channel))
|
||||
);
|
||||
|
||||
socket.on('quit', ({ user, server, reason, channels }) =>
|
||||
|
@ -84,19 +84,22 @@ func (i *ircHandler) join(msg *irc.Message) {
|
||||
}
|
||||
|
||||
func (i *ircHandler) part(msg *irc.Message) {
|
||||
i.session.sendJSON("part", Part{
|
||||
Join: Join{
|
||||
part := Part{
|
||||
Server: i.client.Host,
|
||||
User: msg.Nick,
|
||||
Channels: msg.Params[:len(msg.Params)-1],
|
||||
},
|
||||
Reason: msg.LastParam(),
|
||||
})
|
||||
Channel: msg.Params[0],
|
||||
}
|
||||
|
||||
channelStore.RemoveUser(msg.Nick, i.client.Host, msg.Params[0])
|
||||
if len(msg.Params) == 2 {
|
||||
part.Reason = msg.Params[1]
|
||||
}
|
||||
|
||||
i.session.sendJSON("part", part)
|
||||
|
||||
channelStore.RemoveUser(msg.Nick, i.client.Host, part.Channel)
|
||||
|
||||
if msg.Nick == i.client.GetNick() {
|
||||
go i.session.user.RemoveChannel(i.client.Host, msg.Params[0])
|
||||
go i.session.user.RemoveChannel(i.client.Host, part.Channel)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,13 +85,23 @@ func TestHandleIRCPart(t *testing.T) {
|
||||
})
|
||||
|
||||
checkResponse(t, "part", Part{
|
||||
Join: Join{
|
||||
Server: "host.com",
|
||||
User: "parting",
|
||||
Channels: []string{"#chan"},
|
||||
},
|
||||
Channel: "#chan",
|
||||
Reason: "the reason",
|
||||
}, res)
|
||||
|
||||
res = dispatchMessage(&irc.Message{
|
||||
Command: irc.Part,
|
||||
Nick: "parting",
|
||||
Params: []string{"#chan"},
|
||||
})
|
||||
|
||||
checkResponse(t, "part", Part{
|
||||
Server: "host.com",
|
||||
User: "parting",
|
||||
Channel: "#chan",
|
||||
}, res)
|
||||
}
|
||||
|
||||
func TestHandleIRCMode(t *testing.T) {
|
||||
|
@ -40,7 +40,10 @@ type Join struct {
|
||||
}
|
||||
|
||||
type Part struct {
|
||||
Join
|
||||
Server string `json:"server"`
|
||||
User string `json:"user"`
|
||||
Channel string `json:"channel,omitempty"`
|
||||
Channels []string `json:"channels,omitempty"`
|
||||
Reason string `json:"reason,omitempty"`
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user