1
0
Fork 0
forked from External/ergo

Apply default user modes just before registration.

Previously, we were applying defaults before the user had completed
registration. This meant that the number of invisible users was
incremented when the user connected, and then the total was incremented
when registration was completed.

Now both counters are updated at the same time. If a user disconnects
prior to registration, +i has not yet been applied so it would not be
decremented.
This commit is contained in:
Alex Jaspersen 2020-05-28 15:53:14 +00:00
parent c1d4c5596d
commit 0241e0c31d
6 changed files with 37 additions and 25 deletions

View file

@ -266,11 +266,18 @@ func (server *Server) tryRegister(c *Client, session *Session) (exiting bool) {
return true
}
// Apply default user modes (without updating the invisible counter)
// The number of invisible users will be updated by server.stats.Register
// if we're using default user mode +i.
for _, defaultMode := range server.Config().Accounts.defaultUserModes {
c.SetMode(defaultMode, true)
}
// registration has succeeded:
c.SetRegistered()
// count new user in statistics
server.stats.Register()
server.stats.Register(c.HasMode(modes.Invisible))
server.monitorManager.AlertAbout(c, true)
server.playRegistrationBurst(session)