Jelajahi Sumber

Fix an issue when trying to create a matrix room

It doesn't make sense to create a matrix room for an edit/redaction/reaction
if we don't have the original message. Also we can't as we don't always have
all of the information. So now we don't try to create the room unless it's a
message being created.
Gary Kramlich 3 tahun lalu
induk
melakukan
58aed46f13
1 mengubah file dengan 6 tambahan dan 1 penghapusan
  1. 6 1
      bridge/portal.go

+ 6 - 1
bridge/portal.go

@@ -261,9 +261,14 @@ func (p *Portal) createMatrixRoom(user *User, channel *discordgo.Channel) error
 
 
 func (p *Portal) handleDiscordMessages(msg portalDiscordMessage) {
 func (p *Portal) handleDiscordMessages(msg portalDiscordMessage) {
 	if p.MXID == "" {
 	if p.MXID == "" {
+		discordMsg, ok := msg.msg.(*discordgo.MessageCreate)
+		if !ok {
+			p.log.Warnln("Can't create Matrix room from non new message event")
+			return
+		}
+
 		p.log.Debugln("Creating Matrix room from incoming message")
 		p.log.Debugln("Creating Matrix room from incoming message")
 
 
-		discordMsg := msg.msg.(*discordgo.MessageCreate)
 		channel, err := msg.user.Session.Channel(discordMsg.ChannelID)
 		channel, err := msg.user.Session.Channel(discordMsg.ChannelID)
 		if err != nil {
 		if err != nil {
 			p.log.Errorln("Failed to find channel for message:", err)
 			p.log.Errorln("Failed to find channel for message:", err)