Skip to content

Commit

Permalink
Loop over received attachments (keybase)
Browse files Browse the repository at this point in the history
  • Loading branch information
goncalor committed Oct 27, 2019
1 parent 8d502a8 commit 455c40c
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions bridge/keybase/keybase.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,19 @@ func (b *Bkeybase) Send(msg config.Message) (string, error) {
return "", err
}
defer os.RemoveAll(dir)
fname := msg.Extra["file"][0].(config.FileInfo).Name
fdata := *msg.Extra["file"][0].(config.FileInfo).Data
fcaption := msg.Extra["file"][0].(config.FileInfo).Comment
fpath := filepath.Join(dir, fname)
if err = ioutil.WriteFile(fpath, fdata, 0600); err != nil {
return "", err
}

resp, err := b.kbc.SendAttachmentByTeam(b.team, fpath, fcaption, &b.channel)
return strconv.Itoa(resp.Result.MsgID), err
for _, f := range msg.Extra["file"] {
fname := f.(config.FileInfo).Name
fdata := *f.(config.FileInfo).Data
fcaption := f.(config.FileInfo).Comment
fpath := filepath.Join(dir, fname)
if err = ioutil.WriteFile(fpath, fdata, 0600); err != nil {
return "", err
}

b.kbc.SendAttachmentByTeam(b.team, fpath, fcaption, &b.channel)
}
return "", nil
}

// Send regular message
Expand Down

0 comments on commit 455c40c

Please sign in to comment.