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.
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user