summaryrefslogtreecommitdiffstats
path: root/bridge/slack/slack.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2018-11-25 20:40:22 +0100
committerGitHub <noreply@github.com>2018-11-25 20:40:22 +0100
commitf716b8fc0ff90f47b61e218ef34019b38bd70e0d (patch)
tree16482e0cf327b64e2621c632377c9842cf16c3b1 /bridge/slack/slack.go
parent9f66f93641612028455c43478da2b19e8ee42b8a (diff)
parentf00d4d7d3fe1c3b9366951f461a3f695ebb892fd (diff)
downloadmatterbridge-msglm-f716b8fc0ff90f47b61e218ef34019b38bd70e0d.tar.gz
matterbridge-msglm-f716b8fc0ff90f47b61e218ef34019b38bd70e0d.tar.bz2
matterbridge-msglm-f716b8fc0ff90f47b61e218ef34019b38bd70e0d.zip
Merge pull request #606 from 42wim/fix-590
Diffstat (limited to 'bridge/slack/slack.go')
-rw-r--r--bridge/slack/slack.go17
1 files changed, 13 insertions, 4 deletions
diff --git a/bridge/slack/slack.go b/bridge/slack/slack.go
index 4251f83b..d054ae81 100644
--- a/bridge/slack/slack.go
+++ b/bridge/slack/slack.go
@@ -357,6 +357,10 @@ func (b *Bslack) editMessage(msg *config.Message, channelInfo *slack.Channel) (b
}
func (b *Bslack) postMessage(msg *config.Message, messageParameters *slack.PostMessageParameters, channelInfo *slack.Channel) (string, error) {
+ // don't post empty messages
+ if msg.Text == "" {
+ return "", nil
+ }
for {
_, id, err := b.rtm.PostMessage(channelInfo.ID, msg.Text, *messageParameters)
if err == nil {
@@ -386,11 +390,16 @@ func (b *Bslack) uploadFile(msg *config.Message, channelID string) {
ts := time.Now()
b.Log.Debugf("Adding file %s to cache at %s with timestamp", fi.Name, ts.String())
b.cache.Add("filename"+fi.Name, ts)
+ initialComment := fmt.Sprintf("File from %s", msg.Username)
+ if fi.Comment != "" {
+ initialComment += fmt.Sprintf("with comment: %s", fi.Comment)
+ }
res, err := b.sc.UploadFile(slack.FileUploadParameters{
- Reader: bytes.NewReader(*fi.Data),
- Filename: fi.Name,
- Channels: []string{channelID},
- InitialComment: fi.Comment,
+ Reader: bytes.NewReader(*fi.Data),
+ Filename: fi.Name,
+ Channels: []string{channelID},
+ InitialComment: initialComment,
+ ThreadTimestamp: msg.ParentID,
})
if err != nil {
b.Log.Errorf("uploadfile %#v", err)