forked from jshiffer/matterbridge
Invalidate user in cache on user change event (#1604)
Co-authored-by: Wim <wim@42.be>
This commit is contained in:
parent
b56f80b1b8
commit
b06a574cc5
@ -95,6 +95,8 @@ func (b *Bslack) handleSlackClient(messages chan *config.Message) {
|
||||
b.users.populateUser(ev.User)
|
||||
case *slack.HelloEvent, *slack.LatencyReport, *slack.ConnectingEvent:
|
||||
continue
|
||||
case *slack.UserChangeEvent:
|
||||
b.users.invalidateUser(ev.User.ID)
|
||||
default:
|
||||
b.Log.Debugf("Unhandled incoming event: %T", ev)
|
||||
}
|
||||
|
@ -113,6 +113,12 @@ func (b *users) populateUser(userID string) {
|
||||
b.users[userID] = user
|
||||
}
|
||||
|
||||
func (b *users) invalidateUser(userID string) {
|
||||
b.usersMutex.Lock()
|
||||
defer b.usersMutex.Unlock()
|
||||
delete(b.users, userID)
|
||||
}
|
||||
|
||||
func (b *users) populateUsers(wait bool) {
|
||||
b.refreshMutex.Lock()
|
||||
if !wait && (time.Now().Before(b.earliestRefresh) || b.refreshInProgress) {
|
||||
|
Loading…
Reference in New Issue
Block a user