element-hq / element-ios

A glossy Matrix collaboration client for iOS
https://element.io
Apache License 2.0
1.72k stars 479 forks source link

Incorrect syntax for user mentions #7629

Open progval opened 1 year ago

progval commented 1 year ago

Steps to reproduce

Mention a user from Element iOS nightly. For example: "I DMed tpb about what’s going on but I suspect I’m just talking to a bot/service. 🤔"

Outcome

What did you expect?

This event was sent:

According to the spec:

Something like this should be sent:

{
  "content": {
    "body": "I DMed tpb about what’s going on but I suspect I’m just talking to a bot/service. 🤔",
    "format": "org.matrix.custom.html",
    "formatted_body": "I DMed <a href=\"https://matrix.to/#/@libera_tpb:catircservices.org\">tpb</a> about what’s going on but I suspect I’m just talking to a bot/service. 🤔",
    "msgtype": "m.text"
  },
  ...
}

allowing matrix-appservice-irc to translate it to:


<jevinskie[m]1> I DMed tpb about what’s going on but I suspect I’m just talking to a bot/service. 🤔

What happened instead?

{
  "content": {
    "body": "I DMed [tpb](<https://matrix.to/#/@libera_tpb:catircservices.org>) about what’s going on but I suspect I’m just talking to a bot/service. 🤔",
    "format": "org.matrix.custom.html",
    "formatted_body": "I DMed <a data-mention-type=\"user\" contenteditable=\"false\" href=\"https://matrix.to/#/@libera_tpb:catircservices.org\">tpb</a> about what’s going on but I suspect I’m just talking to a bot/service. 🤔",
    "msgtype": "m.text"
  },
  "origin_server_ts": 1690466951796,
  "room_id": "!LhJjrGmNCUyJajtYYf:catircservices.org",
  "sender": "@jevinskie:matrix.org",
  "type": "m.room.message",
  "unsigned": {
    "age": 4266509
  },
  "event_id": "$30s5H_bel7LYbK_APhXlljW-hXq1bgSiQKjkzeLe-4Q",
  "user_id": "@jevinskie:matrix.org",
  "age": 4266509
}

https://matrix.to/#/!LhJjrGmNCUyJajtYYf:catircservices.org/$30s5H_bel7LYbK_APhXlljW-hXq1bgSiQKjkzeLe-4Q?via=matrix.org&via=catircservices.org

which causes the following to be sent to IRC through matrix-appservice-irc:

<jevinskie[m]1> I DMed [tpb](<https://matrix.to/#/@libera_tpb:catircservices.org>) about what’s going on but I suspect I’m just talking to a bot/service. 🤔

(which then triggers URL snippet fetching, which is very noisy)

Your phone model

No response

Operating system version

No response

Application version

nightly, 1.10.14 (20230621144257)

Homeserver

No response

Will you send logs?

No

jevinskie commented 1 year ago

Here are the message contents. I tried Element X and it doesn't even have the functionality to tap a name to make a mention pill. And indeed I'm on 1.10.14 (20230621144257) from TestFlight.

https://gist.github.com/jevinskie/19fd0fbd7903e1586b5e8b8c6f8cd3a5

jevinskie commented 1 year ago

OK so changing mode: .markdown to mode: .displayname here makes the Markdown that doesn't render in IRC clients go away and also fixes the "bot sees a link" issue. Unfortunately it doesn't display a pill in Element anymore.

View from Element View from IRC

whitequark commented 1 year ago

Thank you for triaging as "Major".