5
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2024-11-26 03:11:37 +00:00

Drop messages not from our mattermost team. Fixes #49

This commit is contained in:
Wim 2016-10-23 21:16:14 +02:00
parent 47d38192b2
commit 545377742c
2 changed files with 8 additions and 1 deletions

View File

@ -31,6 +31,7 @@ type Bmattermost struct {
name string name string
origin string origin string
protocol string protocol string
TeamId string
} }
var flog *log.Entry var flog *log.Entry
@ -75,6 +76,7 @@ func (b *Bmattermost) Connect() error {
go b.mc.WsReceiver() go b.mc.WsReceiver()
} }
go b.handleMatter() go b.handleMatter()
b.TeamId = b.mc.GetTeamId()
return nil return nil
} }
@ -153,7 +155,8 @@ func (b *Bmattermost) handleMatter() {
func (b *Bmattermost) handleMatterClient(mchan chan *MMMessage) { func (b *Bmattermost) handleMatterClient(mchan chan *MMMessage) {
for message := range b.mc.MessageChan { for message := range b.mc.MessageChan {
// do not post our own messages back to irc // do not post our own messages back to irc
if message.Raw.Event == "posted" && b.mc.User.Username != message.Username { // only listen to message from our team
if message.Raw.Event == "posted" && b.mc.User.Username != message.Username && message.Raw.TeamId == b.TeamId {
flog.Debugf("Receiving from matterclient %#v", message) flog.Debugf("Receiving from matterclient %#v", message)
m := &MMMessage{} m := &MMMessage{}
m.Username = message.Username m.Username = message.Username

View File

@ -576,6 +576,10 @@ func (m *MMClient) GetStatus(userId string) string {
return "offline" return "offline"
} }
func (m *MMClient) GetTeamId() string {
return m.Team.Id
}
func (m *MMClient) StatusLoop() { func (m *MMClient) StatusLoop() {
for { for {
if m.WsQuit { if m.WsQuit {