Matrix Client Tutorial

(uhoreg.gitlab.io)

60 points | by whereistimbo 5 hours ago

3 comments

  • alwayslikethis 3 hours ago
    The lack of good clients is really holding Matrix back. Element is rather bloated, and most of the other clients are missing significant amounts of features.
    • ericjmorey 2 hours ago
      I'd say that the protocol itself is what's doing Matrix in.
      • alwayslikethis 2 hours ago
        In order to support bridges to so many different proprietary platforms Matrix needs to have a superset of their features, so the feature creep is probably intentional. It does make it harder for clients to keep up though.
        • cmeacham98 52 minutes ago
          Matrix is the opposite of feature creep - there are several features entirely missing from major clients that users of modern chat apps expect to have.

          (Examples include: custom emoji, functional search of encrypted chats, pinned messages or some sort of MOTD, forwarding messages, etc)

      • isaacaggrey 2 hours ago
        Could you elaborate?
        • dzaima 29 minutes ago
          There are some hilariously ugly things for even trivial things like editing/replies:

          Edits get a `"m.relates_to": {"event_id": ..., "rel_type": "m.replace"}` field in the body, and `"m.new_content": {...}`, containing the plain-text and HTML versions of the message (while also keeping a copy of both, typically with a prepended "*", outside "m.new_content", for backwards compatibility; yes, that's four (4) copies of the message text in an edit; for some while Element generated up to ten (10) copies IIRC, due to some proposed extension, but that seems to be gone thankfully).

          Reply messages get `"m.relates_to": {"m.in_reply_to": {"event_id": ...}}` - an annoyingly different format from the edits. It might look like that that allows an edit to edit the replied-to event, but nope, last I checked, that's not supported. Oh and for backwards compatibility a <mx-reply> HTML element is to be prepended, containing a copy of the replied-to message and its info (and yes, that means that the replied-to message being deleted will result in the reply still containing its text; luckily clients can choose to do not generate such <mx-reply>, but Element still does). And if you want to actually get proper reliable info about the replied-to event, you have to just make an API request for every single one you want to display (unless you happen to already have a cached copy, which luckily for replies is reasonably common).

          And then there's threads - again in the name of crappy backwards-compatibility there's a mess - within-thread replies imitate a reply to the last in-thread message, along with `"m.relates_to": {"event_id": ..., "rel_type": "m.thread", "is_falling_back": true, ...}`, that "is_falling_back" indicating that this isn't actually a reply (being false when you want an actual reply). And clients are "supposed" to also handle replies to in-thread messages without the "m.thread" relation (which'd come from clients not supporting threads), but as far as I can tell there's literally no way do to it properly for going through the transcript without an API request per every single message (and yes Element behaves quite buggily on such).

          This is all possible to handle, of course, but it's hilariously awful.

          But then there are some things that can't be reasonably handled - the context/message listing/pagination APIs don't give any reaction info (besides the reaction events themselves in chronological order of their addition), so reaction presence/counts in history view must be calculated by clients, and thus won't be able to show ones that were posted a while after the messages. (there used to be some aggregation provided, but it's since been removed!!!) I think the only way to do this properly is truly just making an API request of "list reactions" for every single message the client wants to show.

        • ranger_danger 1 hour ago
          • Groxx 32 minutes ago
            All that really shows is "the project has an active community". Have you seen how many XMPP has? Or Python[1]? This is just normal open development metadata.

            [1]: https://peps.python.org/pep-0000/#

  • amstan 29 minutes ago
    I tried to do something similar. It's infuriating how the client must be stateful and have local storage, for both the access_token and even last message recieved. That's right you must remember as the client where the last events [1] you've seen (even if you already told the server to mark it as read) was or else the server will happily send you the same messages over and over again.

    I kind of miss making IRC bots where things were much simpler and ... quicker honestly (latency wise).

    [1] https://uhoreg.gitlab.io/matrix-tutorial/sync.html#:~:text=w...

    • dzaima 19 minutes ago
      At least that means that you will never have messages get dropped due to network issues, or even restarts if you persist the token across such. (the API will jump forwards if there are too many unsynced messages, but at least it should then be providing a "limited: true" so that one can paginate in the omitted events if so desired (or not if undesired))
  • ranger_danger 3 hours ago
    Finally something besides the matrix foundation's "lol the auto-generated API docs are enough" nonsense. This really helps a whole lot better.