Update PostMessage to also return and error. Add EditMessage function

This commit is contained in:
Wim 2017-08-28 00:32:56 +02:00
parent 5a8d7b5f6d
commit e84417430d

View File

@ -451,9 +451,22 @@ func (m *MMClient) GetChannelHeader(channelId string) string {
return ""
}
func (m *MMClient) PostMessage(channelId string, text string) {
func (m *MMClient) PostMessage(channelId string, text string) (string, error) {
post := &model.Post{ChannelId: channelId, Message: text}
m.Client.CreatePost(post)
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)
if resp.Error != nil {
return "", resp.Error
}
return res.Id, nil
}
func (m *MMClient) JoinChannel(channelId string) error {