Fix loop, make megacheck happy

This commit is contained in:
Wim 2017-09-21 23:15:04 +02:00
parent c4b75e5754
commit 7aabe12acf

View File

@ -180,9 +180,12 @@ func (b *Bmattermost) Send(msg config.Message) (string, error) {
return msg.ID, b.mc.DeleteMessage(msg.ID) return msg.ID, b.mc.DeleteMessage(msg.ID)
} }
if msg.Extra != nil { if msg.Extra != nil {
if len(msg.Extra["file"]) > 0 {
var err error
var res, id string
for _, f := range msg.Extra["file"] { for _, f := range msg.Extra["file"] {
fi := f.(config.FileInfo) fi := f.(config.FileInfo)
id, err := b.mc.UploadFile(*fi.Data, b.mc.GetChannelId(channel, ""), fi.Name) id, err = b.mc.UploadFile(*fi.Data, b.mc.GetChannelId(channel, ""), fi.Name)
if err != nil { if err != nil {
flog.Debugf("ERROR %#v", err) flog.Debugf("ERROR %#v", err)
return "", err return "", err
@ -191,7 +194,9 @@ func (b *Bmattermost) Send(msg config.Message) (string, error) {
if b.Config.PrefixMessagesWithNick { if b.Config.PrefixMessagesWithNick {
message = nick + "uploaded a file: " + fi.Name message = nick + "uploaded a file: " + fi.Name
} }
return b.mc.PostMessageWithFiles(b.mc.GetChannelId(channel, ""), message, []string{id}) res, err = b.mc.PostMessageWithFiles(b.mc.GetChannelId(channel, ""), message, []string{id})
}
return res, err
} }
} }
if msg.ID != "" { if msg.ID != "" {