downstream: return channel in cached WHO reply

References: https://github.com/ircdocs/modern-irc/pull/211
This commit is contained in:
Simon Ser 2023-04-05 10:54:43 +02:00
parent 5358d93ab9
commit f12f10a7bb
2 changed files with 17 additions and 2 deletions

View File

@ -2255,6 +2255,9 @@ func (dc *downstreamConn) handleMessageRegistered(ctx context.Context, msg *irc.
Account: uu.Account,
Realname: uu.Realname,
}
if uc.isChannel(mask) {
info.Channel = mask
}
dc.SendMessage(xirc.GenerateWHOXReply(dc.srv.prefix(), dc.nick, fields, &info))
}
dc.SendMessage(&irc.Message{

View File

@ -13,6 +13,7 @@ var whoxFields = []byte("tcuihsnfdlaor")
type WHOXInfo struct {
Token string
Channel string
Username string
Hostname string
Server string
@ -27,7 +28,11 @@ func (info *WHOXInfo) get(k byte) string {
case 't':
return info.Token
case 'c':
return "*"
channel := info.Channel
if channel == "" {
channel = "*"
}
return channel
case 'u':
return info.Username
case 'i':
@ -69,6 +74,8 @@ func (info *WHOXInfo) set(k byte, v string) {
switch k {
case 't':
info.Token = v
case 'c':
info.Channel = v
case 'u':
info.Username = v
case 'h':
@ -96,10 +103,15 @@ func GenerateWHOXReply(prefix *irc.Prefix, nick, fields string, info *WHOXInfo)
hostname = "0" + hostname
}
channel := info.Channel
if channel == "" {
channel = "*"
}
return &irc.Message{
Prefix: prefix,
Command: irc.RPL_WHOREPLY,
Params: []string{nick, "*", info.Username, hostname, info.Server, info.Nickname, info.Flags, "0 " + info.Realname},
Params: []string{nick, channel, info.Username, hostname, info.Server, info.Nickname, info.Flags, "0 " + info.Realname},
}
}