summaryrefslogtreecommitdiffstats
path: root/bridge/slack/helpers.go
diff options
context:
space:
mode:
authorDavid Hill <dhill@mindcry.org>2018-12-15 16:57:54 -0500
committerWim <wim@42.be>2018-12-15 22:57:54 +0100
commit192fe89789cb8d35b0be990b7fb9eb4ae2be9d60 (patch)
treef4eaa616bdf4ef834839d935f39e8112f508b16c /bridge/slack/helpers.go
parent959ca3cef3f4cf2ca45078deb01c1bcdbd17a135 (diff)
downloadmatterbridge-msglm-192fe89789cb8d35b0be990b7fb9eb4ae2be9d60.tar.gz
matterbridge-msglm-192fe89789cb8d35b0be990b7fb9eb4ae2be9d60.tar.bz2
matterbridge-msglm-192fe89789cb8d35b0be990b7fb9eb4ae2be9d60.zip
Populate user on channel join (slack) (#644)
Diffstat (limited to 'bridge/slack/helpers.go')
-rw-r--r--bridge/slack/helpers.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/bridge/slack/helpers.go b/bridge/slack/helpers.go
index ff039c58..6f049561 100644
--- a/bridge/slack/helpers.go
+++ b/bridge/slack/helpers.go
@@ -63,6 +63,26 @@ func (b *Bslack) getChannelBy(lookupKey string, lookupMap map[string]*slack.Chan
const minimumRefreshInterval = 10 * time.Second
+func (b *Bslack) populateUser(userID string) {
+ b.usersMutex.RLock()
+ _, exists := b.users[userID]
+ b.usersMutex.RUnlock()
+ if exists {
+ // already in cache
+ return
+ }
+
+ user, err := b.sc.GetUserInfo(userID)
+ if err != nil {
+ b.Log.Debugf("GetUserInfo failed for %v: %v", userID, err)
+ return
+ }
+
+ b.usersMutex.Lock()
+ b.users[userID] = user
+ b.usersMutex.Unlock()
+}
+
func (b *Bslack) populateUsers() {
b.refreshMutex.Lock()
if time.Now().Before(b.earliestUserRefresh) || b.refreshInProgress {