matrix-org / matrix-appservice-irc

Node.js IRC bridge for Matrix
Apache License 2.0
462 stars 151 forks source link

Missing HL/mention prefix in a reply without a reply fallback #1593

Open progval opened 2 years ago

progval commented 2 years ago

Describe the bug I just noticed an instance of a Matrix user replying to another in #matrix-spec on Libera where the reply is missing the usual $nick: prefix.

I am guessing this is because the client used by the sender implements https://github.com/matrix-org/matrix-spec-proposals/pull/3676

To Reproduce Send the following Matrix events:

{
  "content": {
    "body": "so if i have an event\n```js\n{ \"a\": \"foo\", \"b\": \"bar\" }\n```\nthen an edit\n```js\n{ \"a\": \"baz\" }\n```\nthen another edit\n```js\n{ \"b\": \"qux\" }\n```\nis the final event the content of the last event, or does key `a` still exist?",
    "format": "org.matrix.custom.html",
    "formatted_body": "<p>so if i have an event</p>\n<pre><code class=\"language-js\">{ &quot;a&quot;: &quot;foo&quot;, &quot;b&quot;: &quot;bar&quot; }\n</code></pre>\n<p>then an edit</p>\n<pre><code class=\"language-js\">{ &quot;a&quot;: &quot;baz&quot; }\n</code></pre>\n<p>then another edit</p>\n<pre><code class=\"language-js\">{ &quot;b&quot;: &quot;qux&quot; }\n</code></pre>\n<p>is the final event the content of the last event, or does key <code>a</code> still exist?</p>",
    "m.html": "<p>so if i have an event</p>\n<pre><code class=\"language-js\">{ &quot;a&quot;: &quot;foo&quot;, &quot;b&quot;: &quot;bar&quot; }\n</code></pre>\n<p>then an edit</p>\n<pre><code class=\"language-js\">{ &quot;a&quot;: &quot;baz&quot; }\n</code></pre>\n<p>then another edit</p>\n<pre><code class=\"language-js\">{ &quot;b&quot;: &quot;qux&quot; }\n</code></pre>\n<p>is the final event the content of the last event, or does key <code>a</code> still exist?</p>",
    "m.text": "so if i have an event\n```js\n{ \"a\": \"foo\", \"b\": \"bar\" }\n```\nthen an edit\n```js\n{ \"a\": \"baz\" }\n```\nthen another edit\n```js\n{ \"b\": \"qux\" }\n```\nis the final event the content of the last event, or does key `a` still exist?",
    "msgtype": "m.text"
  },
  "origin_server_ts": 1660529296035,
  "sender": "@tezlm:celery.eu.org",
  "type": "m.room.message",
  "unsigned": {},
  "event_id": "$U3p95E9O7GZpYeRwA0SXpJvkZjxa024udTOJ9Ef2z98",
  "room_id": "!NasysSDfxKxZBzJJoE:matrix.org"
}
{
  "content": {
    "body": "> <@tezlm:celery.eu.org> so if i have an event\n> ```js\n> { \"a\": \"foo\", \"b\": \"bar\" }\n> ```\n> then an edit\n> ```js\n> { \"a\": \"baz\" }\n> ```\n> then another edit\n> ```js\n> { \"b\": \"qux\" }\n> ```\n> is the final event the content of the last event, or does key `a` still exist?\n\nThe `content` is replaced with the `content`.`m.new_content` of the latest event containing a `content`.`m.relates_to` with a `rel_type` of `m.replace`",
    "format": "org.matrix.custom.html",
    "formatted_body": "<mx-reply><blockquote><a href=\"https://matrix.to/#/!NasysSDfxKxZBzJJoE:matrix.org/$U3p95E9O7GZpYeRwA0SXpJvkZjxa024udTOJ9Ef2z98?via=matrix.org&via=libera.chat&via=element.io\">In reply to</a> <a href=\"https://matrix.to/#/@tezlm:celery.eu.org\">@tezlm:celery.eu.org</a><br><p>so if i have an event</p>\n<pre><code class=\"language-js\">{ \"a\": \"foo\", \"b\": \"bar\" }\n</code></pre>\n<p>then an edit</p>\n<pre><code class=\"language-js\">{ \"a\": \"baz\" }\n</code></pre>\n<p>then another edit</p>\n<pre><code class=\"language-js\">{ \"b\": \"qux\" }\n</code></pre>\n<p>is the final event the content of the last event, or does key <code>a</code> still exist?</p></blockquote></mx-reply>The <code>content</code> is replaced with the <code>content</code>.<code>m.new_content</code> of the latest event containing a <code>content</code>.<code>m.relates_to</code> with a <code>rel_type</code> of <code>m.replace</code>",
    "m.relates_to": {
      "m.in_reply_to": {
        "event_id": "$U3p95E9O7GZpYeRwA0SXpJvkZjxa024udTOJ9Ef2z98"
      }
    },
    "msgtype": "m.text",
    "org.matrix.msc1767.message": [
      {
        "body": "> <@tezlm:celery.eu.org> so if i have an event\n> ```js\n> { \"a\": \"foo\", \"b\": \"bar\" }\n> ```\n> then an edit\n> ```js\n> { \"a\": \"baz\" }\n> ```\n> then another edit\n> ```js\n> { \"b\": \"qux\" }\n> ```\n> is the final event the content of the last event, or does key `a` still exist?\n\nThe `content` is replaced with the `content`.`m.new_content` of the latest event containing a `content`.`m.relates_to` with a `rel_type` of `m.replace`",
        "mimetype": "text/plain"
      },
      {
        "body": "<mx-reply><blockquote><a href=\"https://matrix.to/#/!NasysSDfxKxZBzJJoE:matrix.org/$U3p95E9O7GZpYeRwA0SXpJvkZjxa024udTOJ9Ef2z98?via=matrix.org&via=libera.chat&via=element.io\">In reply to</a> <a href=\"https://matrix.to/#/@tezlm:celery.eu.org\">@tezlm:celery.eu.org</a><br><p>so if i have an event</p>\n<pre><code class=\"language-js\">{ \"a\": \"foo\", \"b\": \"bar\" }\n</code></pre>\n<p>then an edit</p>\n<pre><code class=\"language-js\">{ \"a\": \"baz\" }\n</code></pre>\n<p>then another edit</p>\n<pre><code class=\"language-js\">{ \"b\": \"qux\" }\n</code></pre>\n<p>is the final event the content of the last event, or does key <code>a</code> still exist?</p></blockquote></mx-reply>The <code>content</code> is replaced with the <code>content</code>.<code>m.new_content</code> of the latest event containing a <code>content</code>.<code>m.relates_to</code> with a <code>rel_type</code> of <code>m.replace</code>",
        "mimetype": "text/html"
      }
    ]
  },
  "origin_server_ts": 1660531790172,
  "sender": "@waifuchan:matrix.org",
  "type": "m.room.message",
  "unsigned": {
    "age": 19142500
  },
  "event_id": "$7f-BHjrPEO7k05cyyAuOIriB1mKKC6qe8vpv4PqdOc4",
  "room_id": "!NasysSDfxKxZBzJJoE:matrix.org"
}
{
  "content": {
    "body": "ok",
    "format": "org.matrix.custom.html",
    "formatted_body": "<p>ok</p>",
    "m.html": "<p>ok</p>",
    "m.relates_to": {
      "m.in_reply_to": {
        "event_id": "$7f-BHjrPEO7k05cyyAuOIriB1mKKC6qe8vpv4PqdOc4"
      }
    },
    "m.text": "ok",
    "msgtype": "m.text"
  },
  "origin_server_ts": 1660558655281,
  "sender": "@tezlm:celery.eu.org",
  "type": "m.room.message",
  "unsigned": {},
  "event_id": "$u_G8mWD-sNO-7c9Ha-RwAFuyIyCAZPL7Mm_dx_gHsuM",
  "room_id": "!NasysSDfxKxZBzJJoE:matrix.org"
}

It sends this on IRC:

02:08:19 <tezlm[m]> so if i have an event... (full message at https://libera.ems.host/_matrix/media/r0/download/libera.chat/ea1e08696cf5d007c9d7381495b54cf20f984e32)
02:49:52 <waifuchan[m]> > <@tezlm:celery.eu.org> so if i have an event... (full message at https://libera.ems.host/_matrix/media/r0/download/libera.chat/2dc95aadabb24cd4ff8f4c63858f3683564c2f3c)

[lots of unrelated events]

10:17:38 <tezlm[m]> ok

It is unclear that the last message is a reply to the old message.

Expected behavior The last message should be:

10:17:38 <tezlm[m]> waifuchan[m]: ok