5
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2024-11-22 00:00:27 +00:00

Invalidate user in cache on user change event (#1604)

Co-authored-by: Wim <wim@42.be>
This commit is contained in:
Jonathan Walker (Keenan) 2021-10-16 17:36:30 -04:00 committed by GitHub
parent b56f80b1b8
commit b06a574cc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -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)
}

View File

@ -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) {