Make sure we use the configured format string on room name updates

Refs #37
This commit is contained in:
Gary Kramlich
2022-05-02 09:44:12 -05:00
parent 3a1cb2fc78
commit 7d9826fc2d

View File

@@ -413,10 +413,22 @@ func (p *Portal) handleDiscordMessageCreate(user *User, msg *discordgo.Message)
// Handle room name changes
if msg.Type == discordgo.MessageTypeChannelNameChange {
p.Name = msg.Content
channel, err := user.Session.Channel(msg.ChannelID)
if err != nil {
p.log.Errorf("Failed to find the channel for portal %s", p.Key)
return
}
name, err := p.bridge.Config.Bridge.FormatChannelname(channel, user.Session)
if err != nil {
p.log.Errorf("Failed to format name for portal %s", p.Key)
return
}
p.Name = name
p.Update()
p.MainIntent().SetRoomName(p.MXID, msg.Content)
p.MainIntent().SetRoomName(p.MXID, name)
return
}