From 5dcb2bb60c83d12b4d2603eb9b613825915bf01f Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Mon, 26 Oct 2020 15:31:51 -0400 Subject: [PATCH] enhancements to SETNAME Address SETNAME UX problems reported by @KoraggKnightWolf in #oragono: 1. No feedback by default on success or failure 2. Multi-word realnames are not correctly interpreted by some clients --- irc/handlers.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/irc/handlers.go b/irc/handlers.go index 78f34b81..8e7474b4 100644 --- a/irc/handlers.go +++ b/irc/handlers.go @@ -2730,6 +2730,11 @@ func sceneHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Res // SETNAME func setnameHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool { realname := msg.Params[0] + if len(msg.Params) != 0 { + // workaround for clients that turn unknown commands into raw IRC lines, + // so you can do `/setname Jane Doe` in the client and get the expected result + realname = strings.Join(msg.Params, " ") + } if realname == "" { rb.Add(nil, server.name, "FAIL", "SETNAME", "INVALID_REALNAME", client.t("Realname is not valid")) return false @@ -2740,10 +2745,13 @@ func setnameHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *R // alert friends now := time.Now().UTC() - for session := range client.Friends(caps.SetName) { + friends := client.Friends(caps.SetName) + delete(friends, rb.session) + for session := range friends { session.sendFromClientInternal(false, now, "", details.nickMask, details.accountName, nil, "SETNAME", details.realname) } - + // respond to the user unconditionally, even if they don't have the cap + rb.AddFromClient(now, "", details.nickMask, details.accountName, nil, "SETNAME", details.realname) return false }