From fdb57230a363d1326f597253bb230f0e7e325aee Mon Sep 17 00:00:00 2001 From: Wim Date: Sat, 15 Apr 2017 20:21:57 +0200 Subject: Add support for edited messages (mattermost) --- matterclient/matterclient.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'matterclient') diff --git a/matterclient/matterclient.go b/matterclient/matterclient.go index a066d654..d234fb34 100644 --- a/matterclient/matterclient.go +++ b/matterclient/matterclient.go @@ -251,7 +251,7 @@ func (m *MMClient) WsReceiver() { func (m *MMClient) parseMessage(rmsg *Message) { switch rmsg.Raw.Event { - case model.WEBSOCKET_EVENT_POSTED: + case model.WEBSOCKET_EVENT_POSTED, model.WEBSOCKET_EVENT_POST_EDITED: m.parseActionPost(rmsg) /* case model.ACTION_USER_REMOVED: @@ -280,7 +280,17 @@ func (m *MMClient) parseActionPost(rmsg *Message) { rmsg.Username = m.GetUser(data.UserId).Username rmsg.Channel = m.GetChannelName(data.ChannelId) rmsg.Type = data.Type - rmsg.Team = m.GetTeamName(rmsg.Raw.Data["team_id"].(string)) + teamid, _ := rmsg.Raw.Data["team_id"].(string) + // edit messsages have no team_id for some reason + if teamid == "" { + // we can find the team_id from the channelid + result, _ := m.Client.GetChannel(data.ChannelId, "") + teamid = result.Data.(*model.ChannelData).Channel.TeamId + rmsg.Raw.Data["team_id"] = teamid + } + if teamid != "" { + rmsg.Team = m.GetTeamName(teamid) + } // direct message if rmsg.Raw.Data["channel_type"] == "D" { rmsg.Channel = m.GetUser(data.UserId).Username -- cgit v1.2.3