From e706438bb79484a46952740087b3b76d27da119c Mon Sep 17 00:00:00 2001 From: Enmanuel Date: Sun, 8 Mar 2026 18:13:44 +0000 Subject: [PATCH] fix: pasar *MessageEventContent como puntero en SendMarkdown/SendReplyMarkdown/SendThreadMarkdown El metodo OptionalGetRelatesTo() esta definido con pointer receiver en event.MessageEventContent. Al pasarlo como valor (no puntero) a SendMessageEvent, mautrix-go no puede hacer el cast a event.Relatable, getRelatesTo() retorna nil, y el evento m.room.encrypted exterior queda sin m.relates_to. Esto causaba que Element Web no viera la relacion de thread en el evento cifrado exterior y mostrara la respuesta del agente en la timeline principal en lugar del thread, incluso cuando el payload descifrado tenia m.relates_to correcto. Fix: cambiar 'content := event.MessageEventContent{...}' a 'content := &event.MessageEventContent{...}' en los tres metodos de envio. Consistente con el propio uso de mautrix en client.go linea 1161. --- shell/matrix/client.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/shell/matrix/client.go b/shell/matrix/client.go index 7155d49..454ac54 100644 --- a/shell/matrix/client.go +++ b/shell/matrix/client.go @@ -276,7 +276,7 @@ func (c *Client) SendText(ctx context.Context, roomID, text string) error { // FormattedBody contains the HTML rendered by goldmark. func (c *Client) SendMarkdown(ctx context.Context, roomID, markdown string) error { html := mdToHTML(markdown) - content := event.MessageEventContent{ + content := &event.MessageEventContent{ MsgType: event.MsgText, Body: markdown, Format: event.FormatHTML, @@ -309,7 +309,7 @@ func mdToHTML(md string) string { // It sets m.in_reply_to so Matrix clients show the original message as a quote. func (c *Client) SendReplyMarkdown(ctx context.Context, roomID, inReplyTo, markdown string) error { html := mdToHTML(markdown) - content := event.MessageEventContent{ + content := &event.MessageEventContent{ MsgType: event.MsgText, Body: markdown, Format: event.FormatHTML, @@ -329,7 +329,10 @@ func (c *Client) SendThreadMarkdown(ctx context.Context, roomID, threadRootID, i inReplyTo = threadRootID } html := mdToHTML(markdown) - content := event.MessageEventContent{ + // Must use a pointer so mautrix-go can call OptionalGetRelatesTo() (pointer receiver) + // and copy m.relates_to to the outer m.room.encrypted event. Without this, Element + // Web does not see the thread relationship and shows the reply in the main timeline. + content := &event.MessageEventContent{ MsgType: event.MsgText, Body: markdown, Format: event.FormatHTML,