View the history of public and world readable Matrix rooms
Go to file
Eric Eastwood 36925cd603
Add test to make sure the archive doesn't fail when event for event relation is missing and not included in list of provided events (#43)
Add test to make sure the archive doesn't fail when event for event relation is missing and not included in list of provided events. Like if someone is replying to an event that was from long ago out of our range.

In the case of missing relations, Hydrogen does `_loadContextEntryNotInTimeline` because it can't find the event locally which throws an `uncaughtException`. Before https://github.com/matrix-org/matrix-public-archive/pull/51, the `uncaughtException` killed the Hydrogen `child_process` before it could pass back the HTML. Now this PR mainly just adds a test to make sure it works.
```
TypeError: Cannot read properties of undefined (reading 'storeNames')
    at TimelineReader.readById (hydrogen-web\target\lib-build\hydrogen.cjs.js:12483:33)
    at Timeline._getEventFromStorage (hydrogen-web\target\lib-build\hydrogen.cjs.js:12762:46)
    at Timeline._loadContextEntryNotInTimeline (hydrogen-web\target\lib-build\hydrogen.cjs.js:12747:35)
    at Timeline._loadContextEntriesWhereNeeded (hydrogen-web\target\lib-build\hydrogen.cjs.js:12741:14)
    at Timeline.addEntries (hydrogen-web\target\lib-build\hydrogen.cjs.js:12699:10)
    at mountHydrogen (4-hydrogen-vm-render-script.js:204:12)
    at 4-hydrogen-vm-render-script.js:353:1
    at Script.runInContext (node:vm:139:12)
    at _renderHydrogenToStringUnsafe (matrix-public-archive\server\hydrogen-render\3-render-hydrogen-to-string-unsafe.js:102:41)
    at async process.<anonymous> (matrix-public-archive\server\hydrogen-render\2-render-hydrogen-to-string-fork-script.js:18:27)
```
2022-08-29 19:42:18 -05:00
.github/workflows Make sure container is able to start up (#23) 2022-06-15 17:12:44 -05:00
config Make the `child_process` error catching more robust (`uncaughtException`) (#51) 2022-08-29 19:13:56 -05:00
public OpenTelemetry tracing so we can see spans where the app is taking time (#27) 2022-07-14 11:08:50 -05:00
server Add test to make sure the archive doesn't fail when event for event relation is missing and not included in list of provided events (#43) 2022-08-29 19:42:18 -05:00
shared Add test for joining a new federated room (#31) 2022-08-29 18:56:31 -05:00
test Add test to make sure the archive doesn't fail when event for event relation is missing and not included in list of provided events (#43) 2022-08-29 19:42: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 Add app screenshot (#42) 2022-07-18 13:29:47 -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 OpenTelemetry tracing so we can see spans where the app is taking time (#27) 2022-07-14 11:08:50 -05:00
package.json OpenTelemetry tracing so we can see spans where the app is taking time (#27) 2022-07-14 11:08:50 -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.