diff --git a/pkg/connector/matrixfmt/html.go b/pkg/connector/matrixfmt/html.go index 2a19e7b5..95c535eb 100644 --- a/pkg/connector/matrixfmt/html.go +++ b/pkg/connector/matrixfmt/html.go @@ -421,6 +421,9 @@ func (parser *HTMLParser) tagToString(node *html.Node, ctx Context) *EntityStrin ctx = ctx.WithTag(node.Data) switch node.Data { case "blockquote": + if _, isPartialReply := parser.maybeGetAttribute(node, "data-telegram-partial-reply"); isPartialReply { + return NewEntityString("") + } return parser. nodeToTagAwareString(node.FirstChild, ctx). Format(telegramfmt.Style{Type: telegramfmt.StyleBlockquote}) diff --git a/pkg/connector/tomatrix.go b/pkg/connector/tomatrix.go index 2744f6a1..c9633328 100644 --- a/pkg/connector/tomatrix.go +++ b/pkg/connector/tomatrix.go @@ -211,6 +211,7 @@ func (c *TelegramClient) convertToMatrix( ContentHash: hasher.Sum(nil), ContentURI: contentURI, } + if fwd, isForwarded := msg.GetFwdFrom(); isForwarded { err = c.addForwardHeader(ctx, cm.Parts[0], fwd) if err != nil { @@ -229,6 +230,17 @@ func (c *TelegramClient) convertToMatrix( cm.ReplyTo.MessageID = ids.MakeMessageID(portal.PortalKey, replyTo.ReplyToMsgID) } } + if replyTo.Quote { + parsedQuote := c.parseBodyAndHTML(ctx, replyTo.QuoteText, replyTo.QuoteEntities) + parsedQuote.EnsureHasHTML() + existingPart := cm.Parts[0] + existingPart.Content.EnsureHasHTML() + existingPart.Content.FormattedBody = fmt.Sprintf( + "
%s%s", + parsedQuote.FormattedBody, + existingPart.Content.FormattedBody, + ) + } default: log.Warn().Type("reply_to", replyTo).Msg("unhandled reply to type") } @@ -343,7 +355,7 @@ func (t *TelegramClient) addForwardHeader(ctx context.Context, part *bridgev2.Co ) existingFormattedBody := part.Content.FormattedBody if existingFormattedBody != "" { - existingFormattedBody = fmt.Sprintf("
%s
%s", existingFormattedBody) } part.Content.FormattedBody = fmt.Sprintf( "Forwarded message from %s%s",