Perlpimp.net

My own personal ramblings, epiphanies, odd bits of code, and other things worth sharing

Matrix, nodejs, and a bunch of fun

March 01, 2017 | | | Share on Google+

I've been setting up a Matrix server, and wanted to create a bot, which would consume webhook calls from Prometheus and Grafana. This can easily be done if you can settle for not having full end-to-end encryption, which I just had to have.

So having looked at the Go, and Python libraries for Matrix, I found out they did not have olm (end2end) support. So that's a bummer.

I then turned my eyes to the matrix-js-sdk, which could be used with nodejs. Having concluded it must have olm support, as it's the basis for Riot (the defacto client for Matrix currently). I set out to craft the JS code for it.

Though it turns out their built-in olm support is only active inside a browser, that is if the environment has localStorage. So after some googling, I found node-localStorage.

And after a bit of fiddling I made it work. The important bits, which I can share can be found in this snippet on our local gitlab instance.

March 01, 2017 | | | Share on Google+