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, Account: uu.Account,
Realname: uu.Realname, Realname: uu.Realname,
} }
if uc.isChannel(mask) {
info.Channel = mask
}
dc.SendMessage(xirc.GenerateWHOXReply(dc.srv.prefix(), dc.nick, fields, &info)) dc.SendMessage(xirc.GenerateWHOXReply(dc.srv.prefix(), dc.nick, fields, &info))
} }
dc.SendMessage(&irc.Message{ dc.SendMessage(&irc.Message{

View File

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