matrix-org/matrix-appservice-irc

matrix.to links to rooms are bridged only to the room name

Opened this issue · 6 comments

These two messages:

{
  "content": {
    "body": "Is the dev of Neostumbler in here?",
    "msgtype": "m.text"
  },
  "origin_server_ts": 1732228008886,
  "sender": "@axiopaladin:matrix.org",
  "type": "m.room.message",
  "event_id": "$L1E8VDrgneiK1CmWNwTgRdHIyHvAl16Imd6vQbJtJ4Q",
  "room_id": "!rgcVclkrrFiLdpQftu:matrix.org"
}

and

{
  "content": {
    "body": "> <@axiopaladin:matrix.org> Is the dev of Neostumbler in here?\n\nFor that there's NeoStumbler ",
    "format": "org.matrix.custom.html",
    "formatted_body": "<mx-reply><blockquote><a href=\"https://matrix.to/#/!rgcVclkrrFiLdpQftu:matrix.org/$L1E8VDrgneiK1CmWNwTgRdHIyHvAl16Imd6vQbJtJ4Q?via=matrix.teckids.org&via=matrix.org&via=tchncs.de\">In reply to</a> <a href=\"https://matrix.to/#/@axiopaladin:matrix.org\">@axiopaladin:matrix.org</a><br />Is the dev of Neostumbler in here?</blockquote></mx-reply>For that there's <a href=\"https://matrix.to/#/#neostumbler:matrix.org\">#neostumbler:matrix.org</a>",
    "m.relates_to": {
      "m.in_reply_to": {
        "event_id": "$L1E8VDrgneiK1CmWNwTgRdHIyHvAl16Imd6vQbJtJ4Q"
      }
    },
    "msgtype": "m.text"
  },
  "origin_server_ts": 1732228346342,
  "sender": "@pinguin:matrix.teckids.org",
  "type": "m.room.message",
  "event_id": "$H9yC7pOdGJe428SQ2fQc5Rks-hNrdfUBrAUCpTJ8KJo",
  "room_id": "!rgcVclkrrFiLdpQftu:matrix.org"
}

are translated to this on IRC:

22:26:52 <axiopaladin[m]> Is the dev of Neostumbler in here?
22:32:27 <Pinguin[m]> <axiopaladin[m]> "Is the dev of Neostumbler in..." <- For that there's NeoStumbler 

which makes no sense.

The IRC message should contain the matrix.to link.

That's a client issue... clients often put things that make no sense in body. As such other Matrix clients relying on body instead of formatted_body are also affected.

The bridge uses the formatted_body so I don't see how the body is relevant.

I'm pretty sure it uses body.

if (event.content.format === "org.matrix.custom.html") {
htmlText = event.content.formatted_body;
}

That's how it manages to send bold/underline/italics/... to IRC.

f0x52 commented

The bridge tries to use formatted_body when available, but it's very quick to bail https://github.com/matrix-org/matrix-appservice-irc/blob/develop/src/irc/formatting.ts#L178, and then uses just the body as fallback text.
Due to the restrictive tag set, this happens when there are <a> tags (so any links, user mentions, room mentions), <br> so newlines, and replies/blockquotes in the original message.
As the plaintext body loses a lot of context info, this creates for worse bridging, especially due to inconsistency in clients on how they present stuff there. Recently this got even worse with Element X, as mentions are bridged to IRC as their full plaintext markdown syntax... [@mxid:example.com](https://matrix.to/#/@mxid:example.com)

Explains a lot.