~emersion/soju

be3c6d72c17bbf3eb7f4ccac209e1bdd3b9c6914 — Eric Mertens 1 year, 1 month ago 01b28fa
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
2 files changed, 12 insertions(+), 0 deletions(-)

M downstream.go
M upstream.go
M downstream.go => downstream.go +1 -0
@@ 282,6 282,7 @@ var passthroughIsupport = map[string]bool{
	"NICKLEN":       true,
	"PREFIX":        true,
	"SAFELIST":      true,
	"STATUSMSG":     true,
	"TARGMAX":       true,
	"TOPICLEN":      true,
	"USERLEN":       true,

M upstream.go => upstream.go +11 -0
@@ 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)