Преглед изворни кода

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
tags/v2.4.0-rc1
Shivaram Lingamneni пре 3 година
родитељ
комит
5dcb2bb60c
1 измењених фајлова са 10 додато и 2 уклоњено
  1. 10
    2
      irc/handlers.go

+ 10
- 2
irc/handlers.go Прегледај датотеку

@@ -2730,6 +2730,11 @@ func sceneHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Res
2730 2730
 // SETNAME <realname>
2731 2731
 func setnameHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
2732 2732
 	realname := msg.Params[0]
2733
+	if len(msg.Params) != 0 {
2734
+		// workaround for clients that turn unknown commands into raw IRC lines,
2735
+		// so you can do `/setname Jane Doe` in the client and get the expected result
2736
+		realname = strings.Join(msg.Params, " ")
2737
+	}
2733 2738
 	if realname == "" {
2734 2739
 		rb.Add(nil, server.name, "FAIL", "SETNAME", "INVALID_REALNAME", client.t("Realname is not valid"))
2735 2740
 		return false
@@ -2740,10 +2745,13 @@ func setnameHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *R
2740 2745
 
2741 2746
 	// alert friends
2742 2747
 	now := time.Now().UTC()
2743
-	for session := range client.Friends(caps.SetName) {
2748
+	friends := client.Friends(caps.SetName)
2749
+	delete(friends, rb.session)
2750
+	for session := range friends {
2744 2751
 		session.sendFromClientInternal(false, now, "", details.nickMask, details.accountName, nil, "SETNAME", details.realname)
2745 2752
 	}
2746
-
2753
+	// respond to the user unconditionally, even if they don't have the cap
2754
+	rb.AddFromClient(now, "", details.nickMask, details.accountName, nil, "SETNAME", details.realname)
2747 2755
 	return false
2748 2756
 }
2749 2757
 

Loading…
Откажи
Сачувај