Browse Source

fix #1396

* Defer account login snomask until after connection registration is complete
* Don't send account-notify for pre-registration clients
tags/v2.5.0-rc1
Shivaram Lingamneni 3 years ago
parent
commit
c62956f708
2 changed files with 17 additions and 9 deletions
  1. 14
    9
      irc/handlers.go
  2. 3
    0
      irc/server.go

+ 14
- 9
irc/handlers.go View File

@@ -102,21 +102,26 @@ func sendSuccessfulAccountAuth(service *ircService, client *Client, rb *Response
102 102
 		}
103 103
 	}
104 104
 
105
-	// dispatch account-notify
106
-	for friend := range client.Friends(caps.AccountNotify) {
107
-		if friend != rb.session {
108
-			friend.Send(nil, details.nickMask, "ACCOUNT", details.accountName)
105
+	if client.Registered() {
106
+		// dispatch account-notify
107
+		for friend := range client.Friends(caps.AccountNotify) {
108
+			if friend != rb.session {
109
+				friend.Send(nil, details.nickMask, "ACCOUNT", details.accountName)
110
+			}
109 111
 		}
110
-	}
111
-	if rb.session.capabilities.Has(caps.AccountNotify) {
112
-		rb.Add(nil, details.nickMask, "ACCOUNT", details.accountName)
112
+		if rb.session.capabilities.Has(caps.AccountNotify) {
113
+			rb.Add(nil, details.nickMask, "ACCOUNT", details.accountName)
114
+		}
115
+		client.server.sendLoginSnomask(details.nickMask, details.accountName)
113 116
 	}
114 117
 
115
-	client.server.snomasks.Send(sno.LocalAccounts, fmt.Sprintf(ircfmt.Unescape("Client $c[grey][$r%s$c[grey]] logged into account $c[grey][$r%s$c[grey]]"), details.nickMask, details.accountName))
116
-
117 118
 	client.server.logger.Info("accounts", "client", details.nick, "logged into account", details.accountName)
118 119
 }
119 120
 
121
+func (server *Server) sendLoginSnomask(nickMask, accountName string) {
122
+	server.snomasks.Send(sno.LocalAccounts, fmt.Sprintf(ircfmt.Unescape("Client $c[grey][$r%s$c[grey]] logged into account $c[grey][$r%s$c[grey]]"), nickMask, accountName))
123
+}
124
+
120 125
 // AUTHENTICATE [<mechanism>|<data>|*]
121 126
 func authenticateHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool {
122 127
 	session := rb.session

+ 3
- 0
irc/server.go View File

@@ -344,6 +344,9 @@ func (server *Server) playRegistrationBurst(session *Session) {
344 344
 	d := c.Details()
345 345
 	server.logger.Info("connect", fmt.Sprintf("Client connected [%s] [u:%s] [r:%s]", d.nick, d.username, d.realname))
346 346
 	server.snomasks.Send(sno.LocalConnects, fmt.Sprintf("Client connected [%s] [u:%s] [h:%s] [ip:%s] [r:%s]", d.nick, d.username, session.rawHostname, session.IP().String(), d.realname))
347
+	if d.account != "" {
348
+		server.sendLoginSnomask(d.nickMask, d.accountName)
349
+	}
347 350
 
348 351
 	// send welcome text
349 352
 	//NOTE(dan): we specifically use the NICK here instead of the nickmask

Loading…
Cancel
Save