Browse Source

chat: check that a new username is different before sending out updates (#3162)

pull/3164/head
John Regan 2 years ago committed by GitHub
parent
commit
dfa3a2a273
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      core/chat/events.go

6
core/chat/events.go

@ -63,6 +63,12 @@ func (s *Server) userNameChanged(eventData chatClientEvent) {
savedUser := user.GetUserByToken(eventData.client.accessToken) savedUser := user.GetUserByToken(eventData.client.accessToken)
oldName := savedUser.DisplayName oldName := savedUser.DisplayName
// Check that the new name is different from old.
if proposedUsername == oldName {
eventData.client.sendConnectedClientInfo()
return
}
// Save the new name // Save the new name
if err := user.ChangeUsername(eventData.client.User.ID, proposedUsername); err != nil { if err := user.ChangeUsername(eventData.client.User.ID, proposedUsername); err != nil {
log.Errorln("error changing username", err) log.Errorln("error changing username", err)

Loading…
Cancel
Save