commit cbfed0219d02d4225c169f0f596e8f9018a10ea5
Author: Patrick Connolly <patrick.c.connolly@gmail.com>
Date: Wed Nov 28 18:04:26 2018 +0000
diff --git a/bridge/slack/helpers.go b/bridge/slack/helpers.go
index 39fbcea..b0af50f 100644
--- a/bridge/slack/helpers.go
+++ b/bridge/slack/helpers.go
@@ -4423 +4421 @@ func (b *Bslack) getChannel(channel string) (*slack.Channel, error) {
}
func (b *Bslack) getChannelByName(name string) (*slack.Channel, error) {
- b.channelsMutex.RLock()
- defer b.channelsMutex.RUnlock()
-
- if channel, ok := b.channelsByName[name]; ok {
- return channel, nil
- }
- return nil, fmt.Errorf("%s: channel %s not found", b.Account, name)
+ return b.getChannelBy(name, b.channelsByName)
}
func (b *Bslack) getChannelByID(ID string) (*slack.Channel, error) {
+ return b.getChannelBy(ID, b.channelsByID)
+}
+
+func (b *Bslack) getChannelBy(lookupKey string, lookupMap map[string]*slack.Channel) (*slack.Channel, error) {
b.channelsMutex.RLock()
defer b.channelsMutex.RUnlock()
- if channel, ok := b.channelsByID[ID]; ok {
+ if channel, ok := lookupMap[lookupKey]; ok {
return channel, nil
}
- return nil, fmt.Errorf("%s: channel %s not found", b.Account, ID)
+ return nil, fmt.Errorf("%s: channel %s not found", b.Account, lookupKey)
}
const minimumRefreshInterval = 10 * time.Second