forked from jshiffer/matterbridge
Add functions to upload files
This commit is contained in:
parent
b49fb2b69c
commit
6a7adb20a8
@ -467,6 +467,15 @@ func (m *MMClient) PostMessage(channelId string, text string) (string, error) {
|
|||||||
return res.Id, nil
|
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) {
|
func (m *MMClient) EditMessage(postId string, text string) (string, error) {
|
||||||
post := &model.Post{Message: text}
|
post := &model.Post{Message: text}
|
||||||
res, resp := m.Client.UpdatePost(postId, post)
|
res, resp := m.Client.UpdatePost(postId, post)
|
||||||
@ -780,6 +789,14 @@ func (m *MMClient) GetTeamId() string {
|
|||||||
return m.Team.Id
|
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() {
|
func (m *MMClient) StatusLoop() {
|
||||||
retries := 0
|
retries := 0
|
||||||
backoff := time.Second * 60
|
backoff := time.Second * 60
|
||||||
|
Loading…
Reference in New Issue
Block a user