summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Walker (Keenan) <xorith@gmail.com>2021-10-16 17:36:30 -0400
committerGitHub <noreply@github.com>2021-10-16 23:36:30 +0200
commitb06a574cc51feb7195c312ceabb5634275e66d97 (patch)
tree9f93fb0f1d9cf5848353c6a2718d9b488c4286ed
parentb56f80b1b82d58c40919598662ef6184d617976c (diff)
downloadmatterbridge-msglm-b06a574cc51feb7195c312ceabb5634275e66d97.tar.gz
matterbridge-msglm-b06a574cc51feb7195c312ceabb5634275e66d97.tar.bz2
matterbridge-msglm-b06a574cc51feb7195c312ceabb5634275e66d97.zip
Invalidate user in cache on user change event (#1604)
Co-authored-by: Wim <wim@42.be>
-rw-r--r--bridge/slack/handlers.go2
-rw-r--r--bridge/slack/users_channels.go6
2 files changed, 8 insertions, 0 deletions
diff --git a/bridge/slack/handlers.go b/bridge/slack/handlers.go
index d05a358c..4dc57d0d 100644
--- a/bridge/slack/handlers.go
+++ b/bridge/slack/handlers.go
@@ -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)
}
diff --git a/bridge/slack/users_channels.go b/bridge/slack/users_channels.go
index 41fd0bd8..9b34b779 100644
--- a/bridge/slack/users_channels.go
+++ b/bridge/slack/users_channels.go
@@ -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) {