mirror of
https://github.com/42wim/matterbridge.git
synced 2024-11-21 02:02:00 -08:00
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)
|
b.users.populateUser(ev.User)
|
||||||
case *slack.HelloEvent, *slack.LatencyReport, *slack.ConnectingEvent:
|
case *slack.HelloEvent, *slack.LatencyReport, *slack.ConnectingEvent:
|
||||||
continue
|
continue
|
||||||
|
case *slack.UserChangeEvent:
|
||||||
|
b.users.invalidateUser(ev.User.ID)
|
||||||
default:
|
default:
|
||||||
b.Log.Debugf("Unhandled incoming event: %T", ev)
|
b.Log.Debugf("Unhandled incoming event: %T", ev)
|
||||||
}
|
}
|
||||||
|
@ -113,6 +113,12 @@ func (b *users) populateUser(userID string) {
|
|||||||
b.users[userID] = user
|
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) {
|
func (b *users) populateUsers(wait bool) {
|
||||||
b.refreshMutex.Lock()
|
b.refreshMutex.Lock()
|
||||||
if !wait && (time.Now().Before(b.earliestRefresh) || b.refreshInProgress) {
|
if !wait && (time.Now().Before(b.earliestRefresh) || b.refreshInProgress) {
|
||||||
|
Loading…
Reference in New Issue
Block a user