Channel membership prefixes in WHO replies (RPL_WHOREPLY and
RPL_WHOSPCRPL) were cached in the user's flags, which meant those same
prefixes were returned on future cache hits, even though the flags are
channel specific.
Strip the channel membership prefixes from the user's flags before
adding a user to the cache and add the prefixes back when reading from
the cache (using the membership info from the NAMES reply).
---
downstream.go | 5 +++++irc.go | 13 +++++++++++++upstream.go | 5 +++--
3 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/downstream.go b/downstream.go
index f48653e..0853142 100644
--- a/downstream.go+++ b/downstream.go
@@ -2230,6 +2230,11 @@ func (dc *downstreamConn) handleMessageRegistered(ctx context.Context, msg *irc.
}
if uc.isChannel(mask) {
info.Channel = mask
++ // Set channel membership prefixes from cached NAMES reply+ ch := uc.channels.Get(info.Channel)+ memberships := ch.Members.Get(info.Nickname)+ info.Flags += formatMemberPrefix(*memberships, dc)
I think the ordering of the flags isn't quite right here. IRC is a bit
cumbersome here: the channel membership prefix appears in-between the away/op
status and the other server-specific flags [1]. In other words, with the flags
"H*asdf" and the membership prefix "@+", we need to send "H*@+asdf".
strings.IndexFunc might come in handy here to find the index of the first
character other than "H", "G" or "*".
[1]: https://modern.ircdocs.horse/#rplwhoreply-352
On Thursday, June 27th, 2024 at 00:12, Gregory Anders <greg@gpanders.com> wrote:
Thanks a lot for the patch! Just one small comment below, looks good to me
otherwise!