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) {
|
[actions.SOCKET_PART](state, action) {
|
||||||
const { server, channels, user } = action;
|
const { server, channel, user } = action;
|
||||||
const channel = channels[0];
|
|
||||||
if (state.hasIn([server, channel])) {
|
if (state.hasIn([server, channel])) {
|
||||||
return state.updateIn([server, channel, 'users'], users =>
|
return state.updateIn([server, channel, 'users'], users =>
|
||||||
users.filter(u => u.nick !== user)
|
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]))
|
dispatch(inform(`${user} joined the channel`, server, channels[0]))
|
||||||
);
|
);
|
||||||
|
|
||||||
socket.on('part', ({ user, server, channels, reason }) =>
|
socket.on('part', ({ user, server, channel, reason }) =>
|
||||||
dispatch(inform(withReason(`${user} left the channel`, reason), server, channels[0]))
|
dispatch(inform(withReason(`${user} left the channel`, reason), server, channel))
|
||||||
);
|
);
|
||||||
|
|
||||||
socket.on('quit', ({ user, server, reason, channels }) =>
|
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) {
|
func (i *ircHandler) part(msg *irc.Message) {
|
||||||
i.session.sendJSON("part", Part{
|
part := Part{
|
||||||
Join: Join{
|
Server: i.client.Host,
|
||||||
Server: i.client.Host,
|
User: msg.Nick,
|
||||||
User: msg.Nick,
|
Channel: msg.Params[0],
|
||||||
Channels: msg.Params[:len(msg.Params)-1],
|
}
|
||||||
},
|
|
||||||
Reason: msg.LastParam(),
|
|
||||||
})
|
|
||||||
|
|
||||||
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() {
|
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,12 +85,22 @@ func TestHandleIRCPart(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
checkResponse(t, "part", Part{
|
checkResponse(t, "part", Part{
|
||||||
Join: Join{
|
Server: "host.com",
|
||||||
Server: "host.com",
|
User: "parting",
|
||||||
User: "parting",
|
Channel: "#chan",
|
||||||
Channels: []string{"#chan"},
|
Reason: "the reason",
|
||||||
},
|
}, res)
|
||||||
Reason: "the reason",
|
|
||||||
|
res = dispatchMessage(&irc.Message{
|
||||||
|
Command: irc.Part,
|
||||||
|
Nick: "parting",
|
||||||
|
Params: []string{"#chan"},
|
||||||
|
})
|
||||||
|
|
||||||
|
checkResponse(t, "part", Part{
|
||||||
|
Server: "host.com",
|
||||||
|
User: "parting",
|
||||||
|
Channel: "#chan",
|
||||||
}, res)
|
}, res)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,8 +40,11 @@ type Join struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Part struct {
|
type Part struct {
|
||||||
Join
|
Server string `json:"server"`
|
||||||
Reason string `json:"reason,omitempty"`
|
User string `json:"user"`
|
||||||
|
Channel string `json:"channel,omitempty"`
|
||||||
|
Channels []string `json:"channels,omitempty"`
|
||||||
|
Reason string `json:"reason,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Mode struct {
|
type Mode struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user