diff options
author | Wim <wim@42.be> | 2016-11-12 22:00:53 +0100 |
---|---|---|
committer | Wim <wim@42.be> | 2016-11-12 22:00:53 +0100 |
commit | 1d5cd1d7c479c382c9cddaf02f1e59bf55971f12 (patch) | |
tree | abaf22fc41326750e376f0831537bbbbe769d5b2 /matterclient/matterclient.go | |
parent | 08ebee6b4faf677da159db1cffea292050492fd5 (diff) | |
download | matterbridge-msglm-1d5cd1d7c479c382c9cddaf02f1e59bf55971f12.tar.gz matterbridge-msglm-1d5cd1d7c479c382c9cddaf02f1e59bf55971f12.tar.bz2 matterbridge-msglm-1d5cd1d7c479c382c9cddaf02f1e59bf55971f12.zip |
Sync with mattermost 3.5.0
Diffstat (limited to 'matterclient/matterclient.go')
-rw-r--r-- | matterclient/matterclient.go | 48 |
1 files changed, 26 insertions, 22 deletions
diff --git a/matterclient/matterclient.go b/matterclient/matterclient.go index 38be9b00..90c8d1a4 100644 --- a/matterclient/matterclient.go +++ b/matterclient/matterclient.go @@ -264,7 +264,7 @@ func (m *MMClient) parseActionPost(rmsg *Message) { } rmsg.Username = m.GetUser(data.UserId).Username rmsg.Channel = m.GetChannelName(data.ChannelId) - rmsg.Team = m.GetTeamName(rmsg.Raw.TeamId) + rmsg.Team = m.GetTeamName(rmsg.Raw.Data["team_id"].(string)) // direct message if rmsg.Raw.Data["channel_type"] == "D" { rmsg.Channel = m.GetUser(data.UserId).Username @@ -275,7 +275,7 @@ func (m *MMClient) parseActionPost(rmsg *Message) { } func (m *MMClient) UpdateUsers() error { - mmusers, err := m.Client.GetProfilesForDirectMessageList(m.Team.Id) + mmusers, err := m.Client.GetProfiles(0, 1000, "") if err != nil { return errors.New(err.DetailedError) } @@ -305,7 +305,7 @@ func (m *MMClient) GetChannelName(channelId string) string { m.RLock() defer m.RUnlock() for _, t := range m.OtherTeams { - for _, channel := range append(t.Channels.Channels, t.MoreChannels.Channels...) { + for _, channel := range append(*t.Channels, *t.MoreChannels...) { if channel.Id == channelId { return channel.Name } @@ -322,7 +322,7 @@ func (m *MMClient) GetChannelId(name string, teamId string) string { } for _, t := range m.OtherTeams { if t.Id == teamId { - for _, channel := range append(t.Channels.Channels, t.MoreChannels.Channels...) { + for _, channel := range append(*t.Channels, *t.MoreChannels...) { if channel.Name == name { return channel.Id } @@ -336,7 +336,7 @@ func (m *MMClient) GetChannelHeader(channelId string) string { m.RLock() defer m.RUnlock() for _, t := range m.OtherTeams { - for _, channel := range append(t.Channels.Channels, t.MoreChannels.Channels...) { + for _, channel := range append(*t.Channels, *t.MoreChannels...) { if channel.Id == channelId { return channel.Header } @@ -354,7 +354,7 @@ func (m *MMClient) PostMessage(channelId string, text string) { func (m *MMClient) JoinChannel(channelId string) error { m.RLock() defer m.RUnlock() - for _, c := range m.Team.Channels.Channels { + for _, c := range *m.Team.Channels { if c.Id == channelId { m.log.Debug("Not joining ", channelId, " already joined.") return nil @@ -397,7 +397,7 @@ func (m *MMClient) GetPublicLink(filename string) string { if err != nil { return "" } - return res.Data.(string) + return res } func (m *MMClient) GetPublicLinks(filenames []string) []string { @@ -407,7 +407,7 @@ func (m *MMClient) GetPublicLinks(filenames []string) []string { if err != nil { continue } - output = append(output, res.Data.(string)) + output = append(output, res) } return output } @@ -432,15 +432,17 @@ func (m *MMClient) UpdateLastViewed(channelId string) { } func (m *MMClient) UsernamesInChannel(channelId string) []string { - ceiRes, err := m.Client.GetChannelExtraInfo(channelId, 5000, "") + res, err := m.Client.GetMyChannelMembers() if err != nil { m.log.Errorf("UsernamesInChannel(%s) failed: %s", channelId, err) return []string{} } - extra := ceiRes.Data.(*model.ChannelExtra) + members := res.Data.(*model.ChannelMembers) result := []string{} - for _, member := range extra.Members { - result = append(result, member.Username) + for _, channel := range *members { + if channel.ChannelId == channelId { + result = append(result, m.GetUser(channel.UserId).Username) + } } return result } @@ -500,10 +502,10 @@ func (m *MMClient) GetChannels() []*model.Channel { defer m.RUnlock() var channels []*model.Channel // our primary team channels first - channels = append(channels, m.Team.Channels.Channels...) + channels = append(channels, *m.Team.Channels...) for _, t := range m.OtherTeams { if t.Id != m.Team.Id { - channels = append(channels, t.Channels.Channels...) + channels = append(channels, *t.Channels...) } } return channels @@ -515,7 +517,7 @@ func (m *MMClient) GetMoreChannels() []*model.Channel { defer m.RUnlock() var channels []*model.Channel for _, t := range m.OtherTeams { - channels = append(channels, t.MoreChannels.Channels...) + channels = append(channels, *t.MoreChannels...) } return channels } @@ -526,8 +528,8 @@ func (m *MMClient) GetTeamFromChannel(channelId string) string { defer m.RUnlock() var channels []*model.Channel for _, t := range m.OtherTeams { - channels = append(channels, t.Channels.Channels...) - channels = append(channels, t.MoreChannels.Channels...) + channels = append(channels, *t.Channels...) + channels = append(channels, *t.MoreChannels...) for _, c := range channels { if c.Id == channelId { return t.Id @@ -540,11 +542,13 @@ func (m *MMClient) GetTeamFromChannel(channelId string) string { func (m *MMClient) GetLastViewedAt(channelId string) int64 { m.RLock() defer m.RUnlock() - for _, t := range m.OtherTeams { - if _, ok := t.Channels.Members[channelId]; ok { - return t.Channels.Members[channelId].LastViewedAt + /* + for _, t := range m.OtherTeams { + if _, ok := t.Channels.Members[channelId]; ok { + return t.Channels.Members[channelId].LastViewedAt + } } - } + */ return 0 } @@ -619,7 +623,7 @@ func (m *MMClient) initUser() error { //m.log.Debug("initUser(): loading all team data") for _, v := range initData.Teams { m.Client.SetTeamId(v.Id) - mmusers, _ := m.Client.GetProfiles(v.Id, "") + mmusers, _ := m.Client.GetProfiles(0, 1000, "") t := &Team{Team: v, Users: mmusers.Data.(map[string]*model.User), Id: v.Id} mmchannels, _ := m.Client.GetChannels("") t.Channels = mmchannels.Data.(*model.ChannelList) |