diff options
author | Wim <wim@42.be> | 2017-09-21 21:27:44 +0200 |
---|---|---|
committer | Wim <wim@42.be> | 2017-09-21 21:27:44 +0200 |
commit | 6a7adb20a8f9f54d408f573763bc86d2670a0cf7 (patch) | |
tree | 9f417ebe4a10862b1946156ec65d9a334b013d4c /matterclient/matterclient.go | |
parent | b49fb2b69cf71f2b6eee2232e9f67e5b227f38ec (diff) | |
download | matterbridge-msglm-6a7adb20a8f9f54d408f573763bc86d2670a0cf7.tar.gz matterbridge-msglm-6a7adb20a8f9f54d408f573763bc86d2670a0cf7.tar.bz2 matterbridge-msglm-6a7adb20a8f9f54d408f573763bc86d2670a0cf7.zip |
Add functions to upload files
Diffstat (limited to 'matterclient/matterclient.go')
-rw-r--r-- | matterclient/matterclient.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/matterclient/matterclient.go b/matterclient/matterclient.go index 9dcf96c2..37d7bc53 100644 --- a/matterclient/matterclient.go +++ b/matterclient/matterclient.go @@ -467,6 +467,15 @@ func (m *MMClient) PostMessage(channelId string, text string) (string, error) { return res.Id, nil } +func (m *MMClient) PostMessageWithFiles(channelId string, text string, fileIds []string) (string, error) { + post := &model.Post{ChannelId: channelId, Message: text, FileIds: fileIds} + res, resp := m.Client.CreatePost(post) + if resp.Error != nil { + return "", resp.Error + } + return res.Id, nil +} + func (m *MMClient) EditMessage(postId string, text string) (string, error) { post := &model.Post{Message: text} res, resp := m.Client.UpdatePost(postId, post) @@ -780,6 +789,14 @@ func (m *MMClient) GetTeamId() string { return m.Team.Id } +func (m *MMClient) UploadFile(data []byte, channelId string, filename string) (string, error) { + f, resp := m.Client.UploadFile(data, channelId, filename) + if resp.Error != nil { + return "", resp.Error + } + return f.FileInfos[0].Id, nil +} + func (m *MMClient) StatusLoop() { retries := 0 backoff := time.Second * 60 |