Add downstream INVITE support

This commit is contained in:
delthas 2020-03-26 06:03:07 +01:00 committed by Simon Ser
parent 3b6e175365
commit 9530df5db0
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
2 changed files with 42 additions and 0 deletions

View File

@ -1236,6 +1236,34 @@ func (dc *downstreamConn) handleMessageRegistered(msg *irc.Message) error {
uc.network.ring.Produce(echoMsg)
}
case "INVITE":
var user, channel string
if err := parseMessageParams(msg, &user, &channel); err != nil {
return err
}
ucChannel, upstreamChannel, err := dc.unmarshalEntity(channel)
if err != nil {
return err
}
ucUser, upstreamUser, err := dc.unmarshalEntity(user)
if err != nil {
return err
}
if ucChannel != ucUser {
return ircError{&irc.Message{
Command: irc.ERR_USERNOTINCHANNEL,
Params: []string{dc.nick, user, channel, "They aren't on that channel"},
}}
}
uc := ucChannel
uc.SendMessageLabeled(dc, &irc.Message{
Command: "INVITE",
Params: []string{upstreamUser, upstreamChannel},
})
default:
dc.logger.Printf("unhandled message: %v", msg)
return newUnknownCommandError(msg.Command)

View File

@ -1045,6 +1045,20 @@ func (uc *upstreamConn) handleMessage(msg *irc.Message) error {
Params: []string{dc.marshalNick(uc, nick), dc.marshalChannel(uc, channel)},
})
})
case irc.RPL_INVITING:
var nick string
var channel string
if err := parseMessageParams(msg, &nick, &channel); err != nil {
return err
}
uc.forEachDownstreamByID(downstreamID, func(dc *downstreamConn) {
dc.SendMessage(&irc.Message{
Prefix: dc.srv.prefix(),
Command: irc.RPL_INVITING,
Params: []string{dc.nick, dc.marshalNick(uc, nick), dc.marshalChannel(uc, channel)},
})
})
case "TAGMSG":
// TODO: relay to downstream connections that accept message-tags
case "ACK":