View the history of public and world readable Matrix rooms
Go to file
Eric Eastwood 57174db6e0
Fix archive not responding in big rooms because homeserver times out on `/context` request
Add `filter={"lazy_load_members":true}` so that `/context` responds without timing out by returning just the state for the sender of the included event. Otherwise, the homeserver returns all state in the room at that point in time which in big rooms, can be 100k member events that we don't care about anyway. Synapse seems to timeout at about the ~5k state event mark.


## Dev notes

Without `filter={"lazy_load_members":true}`, Synapse can only handle ~4k member events (probably state in general) before `/context` times out before it ever responds in the 180 second window. I'm only looking at the member count as a rough proxy but the number of member events + state will be more.


Loads | Member count | Alias | Matrix.to | API request
--- | --- | --- | --- | ---
 | 39k | `#matrix:matrix.org` | [🔗 ](https://matrix.to/#/!OGEhHVWSdvArJzumhm:matrix.org/$xo-tESRNP1Vg1RxLXIfmMeO6dA6-u9XuE2lv6toeKcw?via=matrix.org) | `https://matrix-client.matrix.org/_matrix/client/r0/rooms/!OGEhHVWSdvArJzumhm:matrix.org/context/$xo-tESRNP1Vg1RxLXIfmMeO6dA6-u9XuE2lv6toeKcw?limit=0`
 | 31k |  `#openwisp_general:gitter.im` | [🔗 ](https://matrix.to/#/!RBzfoBeqYcCwLAAenz:gitter.im/$YFjmbmH0NRPmfVsPyxhM0jcK4RFR_CdCigtHSgCTLSc?via=matrix.org) |`https://matrix-client.matrix.org/_matrix/client/r0/rooms/!RBzfoBeqYcCwLAAenz:gitter.im/context/$YFjmbmH0NRPmfVsPyxhM0jcK4RFR_CdCigtHSgCTLSc?limit=0`
 | 16k | `#raspberrypi:matrix.org` | [🔗 ](https://matrix.to/#/!wOlkWNmgkAZFxbTaqj:matrix.org/$WMh_QauoyW6cjFDuUeNgsnUSgDn7C2XlrUnlijhdmdk?via=matrix.org) | `https://matrix-client.matrix.org/_matrix/client/r0/rooms/!wOlkWNmgkAZFxbTaqj:matrix.org/context/$WMh_QauoyW6cjFDuUeNgsnUSgDn7C2XlrUnlijhdmdk?limit=0`
Loads with warm cache | 7.2k | `#element-android:matrix.org` | [🔗 ](https://matrix.to/#/!AZozoWghOYSIAfaZjJ:matrix.org/$Qmb8vmaD91PIM6ROfh-2jApPoJgH2Q7NnjiwRdiEPZE?via=matrix.org) | `https://matrix-client.matrix.org/_matrix/client/r0/rooms/!AZozoWghOYSIAfaZjJ:matrix.org/context/$Qmb8vmaD91PIM6ROfh-2jApPoJgH2Q7NnjiwRdiEPZE?limit=0`
  | 4k | `#nim-science:envs.net` | [🔗 ](https://matrix.to/#/!IpFtPSbgfrZrVcVyti:envs.net/$bDRop4yvjFOl3HMouAyx4mtau-JaAxvBUJ-MqftAm7E?via=matrix.org) | `https://matrix-client.matrix.org/_matrix/client/r0/rooms/!IpFtPSbgfrZrVcVyti:envs.net/context/$bDRop4yvjFOl3HMouAyx4mtau-JaAxvBUJ-MqftAm7E?limit=0`
  | 2.3k | `#nim-webdev:matrix.org` | [🔗 ](https://matrix.to/#/!EoyccMaVGwdqyfKMAL:matrix.org/$VdRyNb1F-gLdDP9nDYK7xAh_LcE822fEfDYWz5re8dE?via=matrix.org) | `https://matrix-client.matrix.org/_matrix/client/r0/rooms/!EoyccMaVGwdqyfKMAL:matrix.org/context/$VdRyNb1F-gLdDP9nDYK7xAh_LcE822fEfDYWz5re8dE?limit=0`
2022-06-29 05:37:40 -05:00
.github/workflows Make sure container is able to start up (#23) 2022-06-15 17:12:44 -05:00
config Working e2e test 2022-02-24 03:27:53 -06:00
public Remove extra body margin causing offset from viewport (#18) 2022-06-10 15:57:22 -05:00
server Fix archive not responding in big rooms because homeserver times out on `/context` request 2022-06-29 05:37:40 -05:00
shared Remove `matrix-bot-sdk` usage in tests (#15) 2022-06-09 20:44:57 -05:00
test Containerize app (make a Docker image for `matrix-public-archive`) (#22) 2022-06-15 02:28:18 -05:00
.eslintignore Fix lints 2022-02-15 21:33:31 -06:00
.eslintrc.json Add lightbox support and Hydrogen URL hashes relative to the room (#12) 2022-06-08 14:03:36 -05:00
.gitignore E2E test but still failing because fetching from start of day before test events happened 2022-02-23 21:25:05 -06:00
.prettierrc.json SSR with linkedom 2022-02-03 23:44:50 -06:00
Dockerfile Fix image not running in K8s (ROSA) (#24) 2022-06-15 18:42:15 -05:00
README.md Easy get the app running steps (#21) 2022-06-15 01:21:10 -05:00
docker-health-check.js Make sure container is able to start up (#23) 2022-06-15 17:12:44 -05:00
package-lock.json Add testing to CI (#20) 2022-06-15 00:59:41 -05:00
package.json Containerize app (make a Docker image for `matrix-public-archive`) (#22) 2022-06-15 02:28:18 -05:00
vite.config.js E2E test but still failing because fetching from start of day before test events happened 2022-02-23 21:25:05 -06:00

README.md

Matrix public archive

NB: This project is very much a work-in-progress (WIP)! Undocumented config/secrets, using a draft branch of Hydrogen, etc.

In the vein of feature parity with Gitter, the goal is to make a public archive site for world_readable Matrix rooms like Gitter's archives which search engines can index and keep all of the content accessible/available. There is already https://view.matrix.org/ (https://github.com/matrix-org/matrix-static) but there is some desire to make something with more Element-feeling polish and loading faster (avoid the slow 502's errors that are frequent on view.matrix.org).

Plan summary

The plan is to server-side render (SSR) the Hydrogen Matrix client on a Node.js server (since both use JavaScript) and serve pages on the fly (probably with some Cloudflare caching on top) when someone requests /archives/${year}/${month}/${day}. To fetch the events for a given day/time, we will use MSC3030's /timestamp_to_event endpoint to jump to a given day in the timeline and fetch the messages from a Matrix homeserver.

Re-using Hydrogen gets us pretty and native(to Element) looking styles and keeps the maintenance burden of supporting more event types in Hydrogen.

Setup

Prerequisites

Get the app running

$ npm install

# Edit config/config.user-overrides.json so that `matrixServerUrl` points to your homeserver
# and has `matrixAccessToken` defined
$ cp config/config.default.json config/config.user-overrides.json

$ npm run start-dev

Development

# We need to use a draft branch of Hydrogen to get the custom changes needed for
# `matrix-public-archive` to run. Hopefully soon, we can get all of the custom
# changes mainlined so this isn't necessary.
$ git clone git@github.com:vector-im/hydrogen-web.git
$ cd hydrogen-web
$ git checkout madlittlemods/matrix-public-archive-scratch-changes
$ yarn install
$ yarn build:sdk
$ cd target/ && npm link && cd ..
$ cd ..

# Now clone and install the `matrix-public-archive` project
$ git clone git@github.com:matrix-org/matrix-public-archive.git
$ cd matrix-public-archive
$ npm install
$ npm link hydrogen-view-sdk
# If you just want to run the tests, you can skip to the "Running tests" section at this point
#
# Edit config/config.user-overrides.json so that `matrixServerUrl` points to your homeserver
# and has `matrixAccessToken` defined
$ cp config/config.default.json config/config.user-overrides.json

# Now we can finally start the app
$ npm run start-dev

Running tests

See the testing readme.