3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-11 06:29:29 +01:00

Merge pull request #1358 from slingamn/setname

enhancements to SETNAME
This commit is contained in:
Shivaram Lingamneni 2020-10-26 13:30:29 -07:00 committed by GitHub
commit c61b09e314
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2730,6 +2730,11 @@ func sceneHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Res
// SETNAME <realname>
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
}