From be3c6d72c17bbf3eb7f4ccac209e1bdd3b9c6914 Mon Sep 17 00:00:00 2001 From: Eric Mertens Date: Sat, 26 Aug 2023 03:37:20 -0700 Subject: [PATCH] Add support for STATUSMSG This passes the STATUSMSG isupport through, and it ignores statusmsg prefix when routing messages through the PRIVMSG, NOTICE, and TAGMSG handler so they will show up in the correct history. Because it doesn't modify the message the statusmsg sigils show up correctly for the user on receipt. Without this PR the statusmsg messages still come through to the client, but they get misrouted by clients expecting STATUSMSG to be specified in 005 and they don't go into the right channel history. Closes: https://todo.sr.ht/~emersion/soju/124 --- downstream.go | 1 + upstream.go | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/downstream.go b/downstream.go index fbb92a8..460c061 100644 --- a/downstream.go +++ b/downstream.go @@ -282,6 +282,7 @@ var passthroughIsupport = map[string]bool{ "NICKLEN": true, "PREFIX": true, "SAFELIST": true, + "STATUSMSG": true, "TARGMAX": true, "TOPICLEN": true, "USERLEN": true, diff --git a/upstream.go b/upstream.go index 6b3a5b5..979bb60 100644 --- a/upstream.go +++ b/upstream.go @@ -199,6 +199,7 @@ type upstreamConn struct { availableUserModes string availableChannelModes map[byte]channelModeType availableChannelTypes string + availableStatusMsg string availableMemberships []xirc.Membership isupport map[string]*string @@ -373,6 +374,7 @@ func connectToUpstream(ctx context.Context, network *network) (*upstreamConn, er batches: make(map[string]upstreamBatch), serverPrefix: &irc.Prefix{Name: "*"}, availableChannelTypes: stdChannelTypes, + availableStatusMsg: "", availableChannelModes: stdChannelModes, availableMemberships: stdMemberships, isupport: make(map[string]*string), @@ -632,6 +634,9 @@ func (uc *upstreamConn) handleMessage(ctx context.Context, msg *irc.Message) err } } + // remove statusmsg sigils from target + target = strings.TrimLeft(target, uc.availableStatusMsg) + if uc.network.equalCasemap(msg.Prefix.Name, serviceNick) { uc.logger.Printf("skipping %v from soju's service: %v", msg.Command, msg) break @@ -973,6 +978,12 @@ func (uc *upstreamConn) handleMessage(ctx context.Context, msg *irc.Message) err } else { uc.availableChannelTypes = stdChannelTypes } + case "STATUSMSG": + if !negate { + uc.availableStatusMsg = value + } else { + uc.availableStatusMsg = "" + } case "PREFIX": if !negate { err = uc.handleMemberships(value)