Do not panic when changing tiers, and user is nil
parent
d92d1ad974
commit
67b45455b8
|
@ -330,9 +330,13 @@ func (v *visitor) SetUser(u *user.User) {
|
|||
v.mu.Lock()
|
||||
defer v.mu.Unlock()
|
||||
shouldResetLimiters := v.user.TierID() != u.TierID() // TierID works with nil receiver
|
||||
v.user = u
|
||||
v.user = u // u may be nil!
|
||||
if shouldResetLimiters {
|
||||
v.resetLimitersNoLock(u.Stats.Messages, u.Stats.Emails, true)
|
||||
var messages, emails int64
|
||||
if u != nil {
|
||||
messages, emails = u.Stats.Messages, u.Stats.Emails
|
||||
}
|
||||
v.resetLimitersNoLock(messages, emails, true)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue