(incomplete) handle title changes from mattermost to matrix

This commit is contained in:
Alex 2020-02-18 16:14:31 +01:00
parent 62ca33fd0a
commit 78c7d1deae

View file

@ -245,6 +245,7 @@ func (mm *Mattermost) handleLoop(msgCh chan *matterclient.Message, quitCh chan b
case <-quitCh: case <-quitCh:
break break
case msg := <-msgCh: case msg := <-msgCh:
fmt.Printf("Mattermost: %#v\n", msg)
if len(strings.Split(msg.Channel, "__")) == 2 { if len(strings.Split(msg.Channel, "__")) == 2 {
// Private message // Private message
ids := strings.Split(msg.Channel, "__") ids := strings.Split(msg.Channel, "__")
@ -278,6 +279,20 @@ func (mm *Mattermost) handleLoop(msgCh chan *matterclient.Message, quitCh chan b
} }
user := UserID(fmt.Sprintf("%s@%s", msg.Username, mm.server)) user := UserID(fmt.Sprintf("%s@%s", msg.Username, mm.server))
if strings.Contains(msg.Text, "updated the channel header") {
splits := strings.SplitN(msg.Text, "to: ", 2)
if len(splits) == 2 {
if user == mm.User() {
user = UserID("")
}
mm.handler.RoomInfoUpdated(room, user, &RoomInfo{
Topic: splits[1],
})
continue
}
}
if user == mm.User() { if user == mm.User() {
continue continue
} }