The tale of how I got bogged down in the Matrix
For those who nevertheless decide to raise a large server focused on a large user base, it will be very useful to know how moderate in the Matrix… I hope my appeal will be heard, and, some time after the publication of this article, new public servers will appear in the federation 🙂
But in order not to look like one of those who tells everyone what to do, while he himself does nothing … While I was writing this article, I managed to raise and configure my own Synapse Matrix server. It is worth noting that the process of raising the Matrix server and connecting it to the federation, in my opinion, turned out to be easier than raising the mail server.
To get some good out of my server, I decided to integrate it with my site. Stas’M Corp. The fact is that my website has existed for a very long time, since 2009, is located on free hosting from uCoz, and has its own rather rich history. From the very beginning, the site had a mini-chat in which registered users could leave messages, like in a guestbook. The chat had a limit of 500 characters per message, and a maximum of 30 messages in the feed. That is, if there were already 30 messages in the chat, when a new message was sent, the last old message was irretrievably lost.
Thanks to the fact that old copies of mini-chat pages were preserved in the Wayback Machine, it was possible to restore about half of the entire message history – from 2013 to the present day, but with losses, especially in those time windows when there were active discussions in the chat. Some of the events were also restored due to the fact that uCoz carefully stores the logs of all actions on the site from the moment of its creation (but for some reason it does not store messages sent to the mini-chat). The received history of mini-chat messages from the web archive was successfully parsed and imported into a public room on the Matrix server. To match the timestamps of events and messages in the room as they actually were, I slightly modified the server source code. like this – a small file is placed in the server directory timeshift.json
, in which I set the time offset in seconds for a specific room (or for a specific account with which I create a room). Since the Apache web server is running on the same machine, it was easy to script the modification of this file through PHP.
Writing all the scripts (importing messages, importing chat users from the site with their names and avatars, displaying a preview of the chat on the site, as well as the ability to enter new people into the chat from the site) took me about 6 days. All scripts are written in PHP, but I have not yet decided to publish them anywhere.
In addition to the Synapse server, I also raised my Element web client instance, which I also slightly modifiedso that users can enter it without entering a password. Since the login and registration of users on my site works through a third-party uCoz UID system, I did not dare to integrate the login to the chat specifically with it, because in this case I would be able to intercept the passwords of the UID users, which is not very legal. Instead, I implemented temporary password login, as well as generation of a random permanent password when the user first logs into the chat. Checking that the user is actually logged into the site works due to the fact that the cookies of the main domain also apply to all subdomains. It may not be very safe, but it does open up such interesting possibilities. If they suddenly want to close this feature, there will be at least two more alternative ways of checking – send cookies directly via an HTTPS request (fortunately, uCoz allows you to disable the binding of cookies to an IP address), or in a more complex way through modifying the user profile – but here the user will need to enter captcha every time you enter the chat (perhaps not very convenient for both the user and the would-be programmer, but safe).
It all looks like this:
In general, now everything is working as intended. The server is connected to the federation, which means that you can go to it from other servers, and also from it to others. I published the news about the move of the mini-chat to Matrix technology here… And yes, it is likely that the habra effect will put the server I raised … I can only hope that not for long: D
The Matrix has a weekly roundup This Week in Matrix, I will note some of the features that I personally liked.
Have you seen somewhere, at least in some messenger, that you can react to messages with free text? 🙂
Reacting with non-standard emoticons is also possible, at least at the protocol level, it’s just that Element doesn’t know how to do it yet.
And with the help of this widget, you can edit the document with the whole room, almost like in Google Docs:
It can be added to the room with the following command:
/addwidget https://compoventuals-tests.herokuapp.com/host.html?network=matrix&container=demos/rich-text/dist/rich_text.html
Keep in mind that this widget is under development, so don’t use it for anything serious.
I also liked this is the trick, which will definitely be useful for online streamers:
The video shows a really different Matrix client – FluffyChat… I plan to try it in the near future.
While writing the article, I remembered that Jeditobe also had an article about a decentralized messenger, but working on top of email – Delta Chat.
Do you think there is a bridge that could connect Delta Chat and Matrix? Combining two federated platforms sounds strong to me. I’ll leave it to you as a homework 🙂
In my opinion, the Matrix system is very promising and worthy of attention. I can already see that it has every chance of becoming the de facto standard for fast messaging on the Internet, given the current level of support. And it’s very easy to contribute to the development of this system – by raising your Matrix server, and connecting it to the federation.
Concluding the story, I recommend reading: