From e84417430d02663eb83e1ef8757c3b1bf7609bae Mon Sep 17 00:00:00 2001 From: Wim Date: Mon, 28 Aug 2017 00:32:56 +0200 Subject: Update PostMessage to also return and error. Add EditMessage function --- matterclient/matterclient.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'matterclient') diff --git a/matterclient/matterclient.go b/matterclient/matterclient.go index 53c7809c..f6b942aa 100644 --- a/matterclient/matterclient.go +++ b/matterclient/matterclient.go @@ -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 { -- cgit v1.2.3