5
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2024-11-22 19:40:25 +00:00

Update channels when a new group is created (mattermost)

This commit is contained in:
Wim 2018-10-27 13:20:40 +02:00
parent 107969c09a
commit 74e33b0a51

View File

@ -334,6 +334,8 @@ func (m *MMClient) parseMessage(rmsg *Message) {
if _, ok := user["id"].(string); ok { if _, ok := user["id"].(string); ok {
m.UpdateUser(user["id"].(string)) m.UpdateUser(user["id"].(string))
} }
case "group_added":
m.UpdateChannels()
/* /*
case model.ACTION_USER_REMOVED: case model.ACTION_USER_REMOVED:
m.handleWsActionUserRemoved(&rmsg) m.handleWsActionUserRemoved(&rmsg)
@ -431,6 +433,10 @@ func (m *MMClient) GetChannelName(channelId string) string {
if t.Channels != nil { if t.Channels != nil {
for _, channel := range t.Channels { for _, channel := range t.Channels {
if channel.Id == channelId { if channel.Id == channelId {
if channel.Type == model.CHANNEL_GROUP {
res := strings.Replace(channel.DisplayName, ",", "_", -1)
return strings.Replace(res, " ", "", -1)
}
return channel.Name return channel.Name
} }
} }
@ -438,6 +444,10 @@ func (m *MMClient) GetChannelName(channelId string) string {
if t.MoreChannels != nil { if t.MoreChannels != nil {
for _, channel := range t.MoreChannels { for _, channel := range t.MoreChannels {
if channel.Id == channelId { if channel.Id == channelId {
if channel.Type == model.CHANNEL_GROUP {
res := strings.Replace(channel.DisplayName, ",", "_", -1)
return strings.Replace(res, " ", "", -1)
}
return channel.Name return channel.Name
} }
} }