From 52138301d37649a1fe5737b3704235d2ffe70b35 Mon Sep 17 00:00:00 2001 From: Patrick Connolly Date: Fri, 9 Nov 2018 17:05:34 +0800 Subject: [PATCH] Fixed bug in caching logic. --- bridge/slack/slack.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/bridge/slack/slack.go b/bridge/slack/slack.go index 8030eb9c..405c079f 100644 --- a/bridge/slack/slack.go +++ b/bridge/slack/slack.go @@ -298,7 +298,7 @@ func (b *Bslack) sendRTM(msg config.Message) (string, error) { // Upload a file if it exists. if msg.Extra != nil { for _, rmsg := range helper.HandleExtra(&msg, b.General) { - _, _, err = b.rtm.PostMessage(channelInfo.ID, rmsg.Username+rmsg.Text, *messageParameters) + _, _, err = b.sc.PostMessage(channelInfo.ID, rmsg.Username+rmsg.Text, *messageParameters) if err != nil { b.Log.Error(err) } @@ -384,9 +384,7 @@ func (b *Bslack) uploadFile(msg *config.Message, channelID string) { // we can't match on the file ID yet, so we have to match on the filename too. ts := time.Now() b.Log.Debugf("Adding file %s to cache at %s with timestamp", fi.Name, ts.String()) - if !b.cache.Add("filename"+fi.Name, ts) { - b.Log.Warnf("Failed to add file %s to cache at %s with timestamp", fi.Name, ts.String()) - } + b.cache.Add("filename"+fi.Name, ts) res, err := b.sc.UploadFile(slack.FileUploadParameters{ Reader: bytes.NewReader(*fi.Data), Filename: fi.Name, @@ -399,9 +397,7 @@ func (b *Bslack) uploadFile(msg *config.Message, channelID string) { } if res.ID != "" { b.Log.Debugf("Adding file ID %s to cache with timestamp %s", res.ID, ts.String()) - if !b.cache.Add("file"+res.ID, ts) { - b.Log.Warnf("Failed to add file ID %s to cache with timestamp %s", res.ID, ts.String()) - } + b.cache.Add("file"+res.ID, ts) } } }