From 681a5ff2abeaafee9f3a39afd762840f2887226f Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Mon, 27 Feb 2023 00:46:01 +0200 Subject: [PATCH] Create Matrix user mentions even without double puppeting. Fixes #21 --- formatter_tag.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/formatter_tag.go b/formatter_tag.go index eec1545..c74e4d2 100644 --- a/formatter_tag.go +++ b/formatter_tag.go @@ -262,8 +262,11 @@ func (r *discordTagHTMLRenderer) renderDiscordMention(w util.BufWriter, source [ } switch node := n.(type) { case *astDiscordUserMention: - puppet := node.portal.bridge.GetPuppetByID(strconv.FormatInt(node.id, 10)) - _, _ = fmt.Fprintf(w, `%s`, puppet.MXID, puppet.Name) + if user := node.portal.bridge.GetUserByID(strconv.FormatInt(node.id, 10)); user != nil { + _, _ = fmt.Fprintf(w, `%[1]s`, user.MXID) + } else if puppet := node.portal.bridge.GetPuppetByID(strconv.FormatInt(node.id, 10)); puppet != nil { + _, _ = fmt.Fprintf(w, `%s`, puppet.MXID, puppet.Name) + } return case *astDiscordRoleMention: role := node.portal.bridge.DB.Role.GetByID(node.portal.GuildID, strconv.FormatInt(node.id, 10))