diff options
author | Wim <wim@42.be> | 2017-06-05 21:35:38 +0200 |
---|---|---|
committer | Wim <wim@42.be> | 2017-06-05 21:35:38 +0200 |
commit | 01496cd080a264e22799370322d53163498bdd5f (patch) | |
tree | 1b45eb4ebafc35012ea6085439fe0a4fd019fa35 | |
parent | 6a968ab82a95cd4d4d76cb62cfa977e85e52f407 (diff) | |
download | matterbridge-msglm-01496cd080a264e22799370322d53163498bdd5f.tar.gz matterbridge-msglm-01496cd080a264e22799370322d53163498bdd5f.tar.bz2 matterbridge-msglm-01496cd080a264e22799370322d53163498bdd5f.zip |
Fix panic (mattermost). Closes #186
-rw-r--r-- | matterclient/matterclient.go | 10 |
1 files changed, 9 insertions, 1 deletions
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 { |