Browse Source

Handle channel mentions where portal hasn't been created

Tulir Asokan 3 years ago
parent
commit
b0be1a3c08
1 changed files with 5 additions and 1 deletions
  1. 5 1
      formatter_tag.go

+ 5 - 1
formatter_tag.go

@@ -175,7 +175,11 @@ func (r *discordTagHTMLRenderer) renderDiscordMention(w util.BufWriter, source [
 			Receiver:  "",
 			Receiver:  "",
 		})
 		})
 		if portal != nil {
 		if portal != nil {
-			_, _ = fmt.Fprintf(w, `<a href="https://matrix.to/#/%s?via=%s">%s</a>`, portal.MXID, portal.bridge.AS.HomeserverDomain, portal.Name)
+			if portal.MXID != "" {
+				_, _ = fmt.Fprintf(w, `<a href="https://matrix.to/#/%s?via=%s">%s</a>`, portal.MXID, portal.bridge.AS.HomeserverDomain, portal.Name)
+			} else {
+				_, _ = w.WriteString(portal.Name)
+			}
 			return
 			return
 		}
 		}
 	case *astDiscordCustomEmoji:
 	case *astDiscordCustomEmoji: