From 01496cd080a264e22799370322d53163498bdd5f Mon Sep 17 00:00:00 2001 From: Wim Date: Mon, 5 Jun 2017 21:35:38 +0200 Subject: Fix panic (mattermost). Closes #186 --- matterclient/matterclient.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/matterclient/matterclient.go b/matterclient/matterclient.go index e3633a5f..859c94bc 100644 --- a/matterclient/matterclient.go +++ b/matterclient/matterclient.go @@ -288,7 +288,7 @@ func (m *MMClient) parseActionPost(rmsg *Message) { if m.GetUser(data.UserId) == nil { m.UpdateUsers() } - rmsg.Username = m.GetUser(data.UserId).Username + rmsg.Username = m.GetUserName(data.UserId) rmsg.Channel = m.GetChannelName(data.ChannelId) rmsg.Type = data.Type teamid, _ := rmsg.Raw.Data["team_id"].(string) @@ -621,6 +621,14 @@ func (m *MMClient) GetUser(userId string) *model.User { return m.Users[userId] } +func (m *MMClient) GetUserName(userId string) string { + user := m.GetUser(userId) + if user != nil { + return user.Username + } + return "" +} + func (m *MMClient) GetStatus(userId string) string { res, err := m.Client.GetStatuses() if err != nil { -- cgit v1.2.3