Rename project from "Matrix Public Archive" to "Matrix Viewer" (#280)
Mentioned in the recent blog post: https://matrix.org/blog/2023/07/what-happened-with-the-archive/#next-steps The canonical `view.matrix.org` instance is not live yet but this is pre-requisite work for that to happen.
This commit is contained in:
parent
1d1d7d2d0d
commit
5d444d5044
|
@ -8,11 +8,11 @@ on:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY: ghcr.io
|
REGISTRY: ghcr.io
|
||||||
GHCR_NAMESPACE: matrix-org/matrix-public-archive
|
GHCR_NAMESPACE: matrix-org/matrix-viewer
|
||||||
IMAGE_NAME: matrix-public-archive
|
IMAGE_NAME: matrix-viewer
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# Create and publish a Docker image for matrix-public-archive
|
# Create and publish a Docker image for matrix-viewer
|
||||||
#
|
#
|
||||||
# Based off of
|
# Based off of
|
||||||
# https://docs.github.com/en/actions/publishing-packages/publishing-docker-images#publishing-images-to-github-packages
|
# https://docs.github.com/en/actions/publishing-packages/publishing-docker-images#publishing-images-to-github-packages
|
||||||
|
@ -83,7 +83,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
services:
|
services:
|
||||||
matrix-public-archive:
|
matrix-viewer:
|
||||||
image: ${{ needs.build-image.outputs.docker_image_name }}:sha-${{ github.sha }}
|
image: ${{ needs.build-image.outputs.docker_image_name }}:sha-${{ github.sha }}
|
||||||
credentials:
|
credentials:
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
|
|
|
@ -8,8 +8,8 @@ on:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY: ghcr.io
|
REGISTRY: ghcr.io
|
||||||
GHCR_NAMESPACE: matrix-org/matrix-public-archive
|
GHCR_NAMESPACE: matrix-org/matrix-viewer
|
||||||
IMAGE_NAME: matrix-public-archive-test-homeserver
|
IMAGE_NAME: matrix-viewer-test-homeserver
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# Create and publish a Docker image for a Synapse test instance that can
|
# Create and publish a Docker image for a Synapse test instance that can
|
||||||
|
|
32
CHANGELOG.md
32
CHANGELOG.md
|
@ -1,24 +1,24 @@
|
||||||
# 0.2.0 - _upcoming_
|
# 0.2.0 - _upcoming_ - Matrix Viewer
|
||||||
|
|
||||||
- Prevent Cloudflare from overriding our own 504 timeout page, https://github.com/matrix-org/matrix-public-archive/pull/228
|
- Prevent Cloudflare from overriding our own 504 timeout page, https://github.com/matrix-org/matrix-viewer/pull/228
|
||||||
- Catch NSFW rooms with underscores, https://github.com/matrix-org/matrix-public-archive/pull/231
|
- Catch NSFW rooms with underscores, https://github.com/matrix-org/matrix-viewer/pull/231
|
||||||
- Fix `18+` false positives with NSFW check, https://github.com/matrix-org/matrix-public-archive/pull/279
|
- Fix `18+` false positives with NSFW check, https://github.com/matrix-org/matrix-viewer/pull/279
|
||||||
- Fix room cards sorting in the wrong direction on Firefox, https://github.com/matrix-org/matrix-public-archive/pull/261
|
- Fix room cards sorting in the wrong direction on Firefox, https://github.com/matrix-org/matrix-viewer/pull/261
|
||||||
- Remove `libera.chat` as a default since their rooms are not accessible in the archive, https://github.com/matrix-org/matrix-public-archive/pull/263
|
- Remove `libera.chat` as a default since their rooms are not accessible, https://github.com/matrix-org/matrix-viewer/pull/263
|
||||||
- Add reason why the archive bot is joining the room, https://github.com/matrix-org/matrix-public-archive/pull/262
|
- Add reason why the bot is joining the room, https://github.com/matrix-org/matrix-viewer/pull/262
|
||||||
- Add `/faq` redirect, https://github.com/matrix-org/matrix-public-archive/pull/265
|
- Add `/faq` redirect, https://github.com/matrix-org/matrix-viewer/pull/265
|
||||||
- Use `rel=canonical` link to de-duplicate event permalinks, https://github.com/matrix-org/matrix-public-archive/pull/266, https://github.com/matrix-org/matrix-public-archive/pull/269
|
- Use `rel=canonical` link to de-duplicate event permalinks, https://github.com/matrix-org/matrix-viewer/pull/266, https://github.com/matrix-org/matrix-viewer/pull/269
|
||||||
- Prevent join event spam with stable `reason`, https://github.com/matrix-org/matrix-public-archive/pull/268
|
- Prevent join event spam with stable `reason`, https://github.com/matrix-org/matrix-viewer/pull/268
|
||||||
- Don't allow previewing `shared` history rooms, https://github.com/matrix-org/matrix-public-archive/pull/239
|
- Don't allow previewing `shared` history rooms, https://github.com/matrix-org/matrix-viewer/pull/239
|
||||||
- Contributed by [@tulir](https://github.com/tulir)
|
- Contributed by [@tulir](https://github.com/tulir)
|
||||||
- Update FAQ to explain `world_readable` only, https://github.com/matrix-org/matrix-public-archive/pull/277
|
- Update FAQ to explain `world_readable` only, https://github.com/matrix-org/matrix-viewer/pull/277
|
||||||
- Indicate when the room was set to `world_readable` and by who, https://github.com/matrix-org/matrix-public-archive/pull/278
|
- Indicate when the room was set to `world_readable` and by who, https://github.com/matrix-org/matrix-viewer/pull/278
|
||||||
- Only show `world_readable` rooms in the room directory, https://github.com/matrix-org/matrix-public-archive/pull/276
|
- Only show `world_readable` rooms in the room directory, https://github.com/matrix-org/matrix-viewer/pull/276
|
||||||
|
|
||||||
Developer facing:
|
Developer facing:
|
||||||
|
|
||||||
- Fix eslint trying to look at `node_modules/`, https://github.com/matrix-org/matrix-public-archive/pull/275
|
- Fix eslint trying to look at `node_modules/`, https://github.com/matrix-org/matrix-viewer/pull/275
|
||||||
|
|
||||||
# 0.1.0 - 2023-05-11
|
# 0.1.0 - 2023-05-11
|
||||||
|
|
||||||
- Initial public release with good enough functionality to be generally available including: room directory homepage, room archive view with calendar jump-to-date, drill-down with the time selector, following room upgrades (tombstone/predecessor), and more. Completed milestone: https://github.com/matrix-org/matrix-public-archive/milestone/1
|
- Initial public release with good enough functionality to be generally available including: room directory homepage, room archive view with calendar jump-to-date, drill-down with the time selector, following room upgrades (tombstone/predecessor), and more. Completed milestone: https://github.com/matrix-org/matrix-viewer/milestone/1
|
||||||
|
|
33
README.md
33
README.md
|
@ -1,21 +1,28 @@
|
||||||
# Matrix Public Archive
|
# Matrix Viewer
|
||||||
|
|
||||||
<a href="https://matrix.to/#/#matrix-public-archive:matrix.org"><img src="https://img.shields.io/matrix/matrix-public-archive:matrix.org.svg?label=%23matrix-public-archive%3Amatrix.org&logo=matrix&server_fqdn=matrix.org" alt="Join the community and get support at #matrix-public-archive:matrix.org" /></a>
|
<a href="https://matrix.to/#/#matrix-viewer:matrix.org"><img src="https://img.shields.io/matrix/matrix-viewer:matrix.org.svg?label=%23matrix-viewer%3Amatrix.org&logo=matrix&server_fqdn=matrix.org" alt="Join the community and get support at #matrix-viewer:matrix.org" /></a>
|
||||||
|
|
||||||
|
> **Note**
|
||||||
|
> The Matrix Public Archive has been renamed to Matrix Viewer to better reflect what it
|
||||||
|
> actually does and doesn't do. It's a viewer for world-readable Matrix rooms and
|
||||||
|
> doesn't actually archive anything.
|
||||||
|
|
||||||
In the vein of [feature parity with
|
In the vein of [feature parity with
|
||||||
Gitter](https://github.com/vector-im/roadmap/issues/26), the goal is to make a
|
Gitter](https://github.com/vector-im/roadmap/issues/26), the goal is to make an
|
||||||
public archive site for `world_readable` Matrix rooms like Gitter's archives
|
accessible public site for `world_readable` Matrix rooms like Gitter's archives
|
||||||
which search engines can index and keep all of the content accessible/available.
|
which search engines can index and keep all of the content accessible/available.
|
||||||
|
|
||||||
#### Try it out: [archive.matrix.org](https://archive.matrix.org/) 🌌
|
#### Try it out: [view.matrix.org](https://view.matrix.org/) 🌌
|
||||||
|
|
||||||
<!-- prettier-ignore -->
|
<!-- prettier-ignore -->
|
||||||
Room directory homepage | Archive room view
|
Room directory homepage | Room view
|
||||||
--- | ---
|
--- | ---
|
||||||
<img alt="A reference for how the Matrix Public Archive homepage looks. Search bar where you can find thousands of rooms using Matrix and homeserver selector. Grid of room cards showing the results." src="https://user-images.githubusercontent.com/558581/236579462-fee0f9c0-29d2-4c3d-a695-c9eaf0f744ef.png" width="440"> | ![A reference for how the Matrix Public Archive looks. Showing off a day of messages in `#gitter:matrix.org` on 2021-08-06. There is a date picker calendar in the right sidebar and a traditional chat app layout on the left.](https://user-images.githubusercontent.com/558581/234765275-28c70c49-c27f-473a-88ba-f4392ddae871.png)
|
<img alt="A reference for how the Matrix Viewer homepage looks. Search bar where you can find thousands of rooms using Matrix and homeserver selector. Grid of room cards showing the results." src="https://user-images.githubusercontent.com/558581/236579462-fee0f9c0-29d2-4c3d-a695-c9eaf0f744ef.png" width="440"> | ![A reference for how the Matrix Viewer looks. Showing off a day of messages in `#gitter:matrix.org` on 2021-08-06. There is a date picker calendar in the right sidebar and a traditional chat app layout on the left.](https://user-images.githubusercontent.com/558581/234765275-28c70c49-c27f-473a-88ba-f4392ddae871.png)
|
||||||
|
|
||||||
## Demo videos
|
## Demo videos
|
||||||
|
|
||||||
|
The demo's refer to this project as the "Matrix Public Archive" which has now been renamed to "Matrix Viewer".
|
||||||
|
|
||||||
- [![](https://user-images.githubusercontent.com/558581/206083768-d18456de-caa3-463f-a891-96eed8054686.png) May 2023](https://www.youtube.com/watch?v=4KlNILNItGQ&t=1046s): Introducing [archive.matrix.org](https://archive.matrix.org/), the shiny new public instance of the Matrix Public Archive that everyone can share and link to.
|
- [![](https://user-images.githubusercontent.com/558581/206083768-d18456de-caa3-463f-a891-96eed8054686.png) May 2023](https://www.youtube.com/watch?v=4KlNILNItGQ&t=1046s): Introducing [archive.matrix.org](https://archive.matrix.org/), the shiny new public instance of the Matrix Public Archive that everyone can share and link to.
|
||||||
- [![](https://user-images.githubusercontent.com/558581/206083768-d18456de-caa3-463f-a891-96eed8054686.png) Aug 2022](https://www.youtube.com/watch?v=6KHQSeJTXm0&t=583s) ([blog post](https://matrix.org/blog/2022/08/05/this-week-in-matrix-2022-08-05#matrix-public-archive-website)): A quick intro of what the project looks like, the goals, what it accomplishes, and how it's a new portal into the Matrix ecosystem.
|
- [![](https://user-images.githubusercontent.com/558581/206083768-d18456de-caa3-463f-a891-96eed8054686.png) Aug 2022](https://www.youtube.com/watch?v=6KHQSeJTXm0&t=583s) ([blog post](https://matrix.org/blog/2022/08/05/this-week-in-matrix-2022-08-05#matrix-public-archive-website)): A quick intro of what the project looks like, the goals, what it accomplishes, and how it's a new portal into the Matrix ecosystem.
|
||||||
- [![](https://user-images.githubusercontent.com/558581/206083768-d18456de-caa3-463f-a891-96eed8054686.png) Oct 2022](https://www.youtube.com/watch?v=UT6KSEqDUf8&t=548s): Showing off the room directory landing page used to browse everything available in the archive.
|
- [![](https://user-images.githubusercontent.com/558581/206083768-d18456de-caa3-463f-a891-96eed8054686.png) Oct 2022](https://www.youtube.com/watch?v=UT6KSEqDUf8&t=548s): Showing off the room directory landing page used to browse everything available in the archive.
|
||||||
|
@ -25,7 +32,7 @@ Room directory homepage | Archive room view
|
||||||
We server-side render (SSR) the [Hydrogen](https://github.com/vector-im/hydrogen-web)
|
We server-side render (SSR) the [Hydrogen](https://github.com/vector-im/hydrogen-web)
|
||||||
Matrix client on a Node.js server (since both use JavaScript) and serve pages on the fly
|
Matrix client on a Node.js server (since both use JavaScript) and serve pages on the fly
|
||||||
(with some Cloudflare caching on top) when someone requests
|
(with some Cloudflare caching on top) when someone requests
|
||||||
`/archives/r/matrixhq:matrix.org/${year}/${month}/${day}`. To fetch the events for a
|
`/r/matrixhq:matrix.org/${year}/${month}/${day}`. To fetch the events for a
|
||||||
given day/time, we use [MSC3030](https://github.com/matrix-org/matrix-doc/pull/3030)'s
|
given day/time, we use [MSC3030](https://github.com/matrix-org/matrix-doc/pull/3030)'s
|
||||||
`/timestamp_to_event` endpoint to jump to a given day in the timeline and fetch the
|
`/timestamp_to_event` endpoint to jump to a given day in the timeline and fetch the
|
||||||
messages from a Matrix homeserver.
|
messages from a Matrix homeserver.
|
||||||
|
@ -70,9 +77,9 @@ $ npm run start
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
# Clone and install the `matrix-public-archive` project
|
# Clone and install the `matrix-viewer` project
|
||||||
$ git clone git@github.com:matrix-org/matrix-public-archive.git
|
$ git clone git@github.com:matrix-org/matrix-viewer.git
|
||||||
$ cd matrix-public-archive
|
$ cd matrix-viewer
|
||||||
$ npm install
|
$ npm install
|
||||||
|
|
||||||
# Edit `config/config.user-overrides.json` so that `matrixServerUrl` points to
|
# Edit `config/config.user-overrides.json` so that `matrixServerUrl` points to
|
||||||
|
@ -88,7 +95,7 @@ it into this project with the following instructions:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
# We need to use a draft branch of Hydrogen to get the custom changes needed for
|
# 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
|
# `matrix-viewer` to run. Hopefully soon, we can get all of the custom
|
||||||
# changes mainlined so this isn't necessary.
|
# changes mainlined so this isn't necessary.
|
||||||
$ git clone git@github.com:vector-im/hydrogen-web.git
|
$ git clone git@github.com:vector-im/hydrogen-web.git
|
||||||
$ cd hydrogen-web
|
$ cd hydrogen-web
|
||||||
|
@ -98,7 +105,7 @@ $ yarn build:sdk
|
||||||
$ cd target/ && npm link && cd ..
|
$ cd target/ && npm link && cd ..
|
||||||
$ cd ..
|
$ cd ..
|
||||||
|
|
||||||
$ cd matrix-public-archive
|
$ cd matrix-viewer
|
||||||
$ npm link hydrogen-view-sdk
|
$ npm link hydrogen-view-sdk
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -25,14 +25,14 @@ module.exports = defineConfig({
|
||||||
// This doesn't seem to be necessary for the this package to work (ref
|
// This doesn't seem to be necessary for the this package to work (ref
|
||||||
// https://vitejs.dev/guide/dep-pre-bundling.html#monorepos-and-linked-dependencies)
|
// https://vitejs.dev/guide/dep-pre-bundling.html#monorepos-and-linked-dependencies)
|
||||||
//
|
//
|
||||||
//'matrix-public-archive-shared'
|
//'matrix-viewer-shared'
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
// The `file:` packages don't seem resolve correctly so let's add an alias as well
|
// The `file:` packages don't seem resolve correctly so let's add an alias as well
|
||||||
// See https://css-tricks.com/adding-vite-to-your-existing-web-app/#aa-aliases
|
// See https://css-tricks.com/adding-vite-to-your-existing-web-app/#aa-aliases
|
||||||
'matrix-public-archive-shared': path.resolve(__dirname, '../shared'),
|
'matrix-viewer-shared': path.resolve(__dirname, '../shared'),
|
||||||
},
|
},
|
||||||
// This will make sure Vite/Rollup matches the original file path (i.e. the path
|
// This will make sure Vite/Rollup matches the original file path (i.e. the path
|
||||||
// without following symlinks) instead of the real file path (i.e. the path after
|
// without following symlinks) instead of the real file path (i.e. the path after
|
||||||
|
|
|
@ -60,7 +60,7 @@ summary {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Based on .SessionView from Hydrogen */
|
/* Based on .SessionView from Hydrogen */
|
||||||
.ArchiveRoomView {
|
.RoomView {
|
||||||
/* this takes into account whether or not the url bar is hidden on mobile
|
/* this takes into account whether or not the url bar is hidden on mobile
|
||||||
(have tested Firefox Android and Safari on iOS),
|
(have tested Firefox Android and Safari on iOS),
|
||||||
see https://developers.google.com/web/updates/2016/12/url-bar-resizing */
|
see https://developers.google.com/web/updates/2016/12/url-bar-resizing */
|
||||||
|
@ -76,7 +76,7 @@ summary {
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ArchiveRoomView_mainArea {
|
.RoomView_mainArea {
|
||||||
grid-area: middle;
|
grid-area: middle;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
@ -105,7 +105,7 @@ summary {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ArchiveRoomView_mainBody {
|
.RoomView_mainBody {
|
||||||
flex: 1 1;
|
flex: 1 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
@ -114,31 +114,31 @@ summary {
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ArchiveRoomView_mainBody > .Timeline {
|
.RoomView_mainBody > .Timeline {
|
||||||
flex: 1 0;
|
flex: 1 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media screen and (max-width: 800px) {
|
@media screen and (max-width: 800px) {
|
||||||
/* Only the middle needs to be visible mobile by default */
|
/* Only the middle needs to be visible mobile by default */
|
||||||
.ArchiveRoomView {
|
.RoomView {
|
||||||
grid-template:
|
grid-template:
|
||||||
'status' auto
|
'status' auto
|
||||||
'middle' 1fr /
|
'middle' 1fr /
|
||||||
1fr;
|
1fr;
|
||||||
}
|
}
|
||||||
/* Which also means hiding the right-panel by default on mobile */
|
/* Which also means hiding the right-panel by default on mobile */
|
||||||
.ArchiveRoomView:not(.right-shown) .RightPanelView {
|
.RoomView:not(.right-shown) .RightPanelView {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* When the user opens the right-panel, show it */
|
/* When the user opens the right-panel, show it */
|
||||||
.ArchiveRoomView.right-shown {
|
.RoomView.right-shown {
|
||||||
grid-template:
|
grid-template:
|
||||||
'status' auto
|
'status' auto
|
||||||
'right' 1fr /
|
'right' 1fr /
|
||||||
1fr;
|
1fr;
|
||||||
}
|
}
|
||||||
.ArchiveRoomView.right-shown .ArchiveRoomView_mainArea {
|
.RoomView.right-shown .RoomView_mainArea {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
/* And show the button to open the right-panel on mobile */
|
/* And show the button to open the right-panel on mobile */
|
||||||
|
|
Before Width: | Height: | Size: 234 KiB After Width: | Height: | Size: 234 KiB |
|
@ -1,4 +1,4 @@
|
||||||
import 'matrix-public-archive-shared/hydrogen-vm-render-script.js';
|
import 'matrix-viewer-shared/hydrogen-vm-render-script.js';
|
||||||
|
|
||||||
// Assets
|
// Assets
|
||||||
import 'hydrogen-view-sdk/assets/theme-element-light.css';
|
import 'hydrogen-view-sdk/assets/theme-element-light.css';
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
import assert from 'matrix-public-archive-shared/lib/assert.js';
|
import assert from 'matrix-viewer-shared/lib/assert.js';
|
||||||
import MatrixPublicArchiveURLCreator from 'matrix-public-archive-shared/lib/url-creator.js';
|
import MatrixViewerURLCreator from 'matrix-viewer-shared/lib/url-creator.js';
|
||||||
import redirectIfRoomAliasInHash from 'matrix-public-archive-shared/lib/redirect-if-room-alias-in-hash.js';
|
import redirectIfRoomAliasInHash from 'matrix-viewer-shared/lib/redirect-if-room-alias-in-hash.js';
|
||||||
|
|
||||||
// Assets
|
// Assets
|
||||||
import 'hydrogen-view-sdk/assets/theme-element-light.css';
|
import 'hydrogen-view-sdk/assets/theme-element-light.css';
|
||||||
import '../css/styles.css';
|
import '../css/styles.css';
|
||||||
|
|
||||||
const config = window.matrixPublicArchiveContext.config;
|
const config = window.matrixViewerContext.config;
|
||||||
assert(config);
|
assert(config);
|
||||||
assert(config.basePath);
|
assert(config.basePath);
|
||||||
|
|
||||||
const matrixPublicArchiveURLCreator = new MatrixPublicArchiveURLCreator(config.basePath);
|
const matrixViewerURLCreator = new MatrixViewerURLCreator(config.basePath);
|
||||||
|
|
||||||
console.log(`Trying to redirect based on pageHash=${window.location.hash}`);
|
console.log(`Trying to redirect based on pageHash=${window.location.hash}`);
|
||||||
const isRedirecting = redirectIfRoomAliasInHash(matrixPublicArchiveURLCreator);
|
const isRedirecting = redirectIfRoomAliasInHash(matrixViewerURLCreator);
|
||||||
|
|
||||||
// Show the message while we're trying to redirect or if we found nothing, remove the
|
// Show the message while we're trying to redirect or if we found nothing, remove the
|
||||||
// message
|
// message
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import 'matrix-public-archive-shared/room-directory-vm-render-script.js';
|
import 'matrix-viewer-shared/room-directory-vm-render-script.js';
|
||||||
|
|
||||||
// Assets
|
// Assets
|
||||||
import 'hydrogen-view-sdk/assets/theme-element-light.css';
|
import 'hydrogen-view-sdk/assets/theme-element-light.css';
|
||||||
|
@ -8,4 +8,4 @@ import '../css/room-directory.css';
|
||||||
// over for all
|
// over for all
|
||||||
import '../img/favicon.ico';
|
import '../img/favicon.ico';
|
||||||
import '../img/favicon.svg';
|
import '../img/favicon.svg';
|
||||||
import '../img/matrix-public-archive-opengraph.png';
|
import '../img/opengraph.png';
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
"matrixServerName": "localhost",
|
"matrixServerName": "localhost",
|
||||||
// Set this to 100 since that is the max that Synapse will backfill even if you do a
|
// Set this to 100 since that is the max that Synapse will backfill even if you do a
|
||||||
// `/messages?limit=1000` and we don't want to miss messages in between.
|
// `/messages?limit=1000` and we don't want to miss messages in between.
|
||||||
"archiveMessageLimit": 100,
|
"messageLimit": 100,
|
||||||
"requestTimeoutMs": 25000,
|
"requestTimeoutMs": 25000,
|
||||||
"logOutputFromChildProcesses": false,
|
"logOutputFromChildProcesses": false,
|
||||||
//"stopSearchEngineIndexing": true,
|
//"stopSearchEngineIndexing": true,
|
||||||
|
|
|
@ -7,5 +7,5 @@
|
||||||
"testMatrixServerUrl2": "http://localhost:12008/",
|
"testMatrixServerUrl2": "http://localhost:12008/",
|
||||||
|
|
||||||
// Secrets
|
// Secrets
|
||||||
"matrixAccessToken": "as_token_8664700429a911bbbecf7d91b9e1a74716d669f40cf32259630e38439726e29d"
|
"matrixAccessToken": "as_token_matrix_viewer_foobarbaz"
|
||||||
}
|
}
|
||||||
|
|
46
docs/faq.md
46
docs/faq.md
|
@ -2,14 +2,14 @@
|
||||||
|
|
||||||
## Can I run my own instance?
|
## Can I run my own instance?
|
||||||
|
|
||||||
Yes! We host a public canonical version of the Matrix Public Archive at
|
Yes! We host a public canonical version of the Matrix Viewer at
|
||||||
[archive.matrix.org](https://archive.matrix.org/) that everyone can use but feel free to
|
_(incoming)_ that everyone can use but feel free to
|
||||||
also run your own instance (setup instructions in the [readme](../README.md)).
|
also run your own instance (setup instructions in the [readme](../README.md)).
|
||||||
|
|
||||||
## How is this different from [`view.matrix.org`](https://view.matrix.org/)?
|
## How is this different from the `matrix-static` project?
|
||||||
|
|
||||||
https://view.matrix.org/ (https://github.com/matrix-org/matrix-static) already existed
|
[Matrix Static](https://github.com/matrix-org/matrix-static) already existed
|
||||||
before the Matrix Public Archive but there was some desire to make something with more
|
before the Matrix Viewer but there was some desire to make something with more
|
||||||
Element-feeling polish and loading faster (avoid the slow 502's errors that are frequent
|
Element-feeling polish and loading faster (avoid the slow 502's errors that are frequent
|
||||||
on `view.matrix.org`).
|
on `view.matrix.org`).
|
||||||
|
|
||||||
|
@ -17,19 +17,22 @@ And with the introduction of the jump to date API via
|
||||||
[MSC3030](https://github.com/matrix-org/matrix-spec-proposals/pull/3030), we could show
|
[MSC3030](https://github.com/matrix-org/matrix-spec-proposals/pull/3030), we could show
|
||||||
messages from any given date and day-by-day navigation.
|
messages from any given date and day-by-day navigation.
|
||||||
|
|
||||||
## Why did the archive bot join my room?
|
The Matrix Viewer project has since replaced the `matrix-static` project on
|
||||||
|
[`view.matrix.org`](https://view.matrix.org/).
|
||||||
|
|
||||||
|
## Why did the bot join my room?
|
||||||
|
|
||||||
Only Matrix rooms with `world_readable` [history
|
Only Matrix rooms with `world_readable` [history
|
||||||
visibility](https://spec.matrix.org/latest/client-server-api/#room-history-visibility)
|
visibility](https://spec.matrix.org/latest/client-server-api/#room-history-visibility)
|
||||||
are accessible in the Matrix Public Archive and indexed by search engines.
|
are accessible in the Matrix Viewer and indexed by search engines.
|
||||||
|
|
||||||
But the archive bot (`@archive:matrix.org`) will join any public room because it doesn't
|
But the bot (`@view:matrix.org`) will join any public room because it doesn't
|
||||||
know the history visibility without first joining. Any room that doesn't have
|
know the history visibility without first joining. Any room that doesn't have
|
||||||
`world_readable` history visibility will lead a `403 Forbidden`.
|
`world_readable` history visibility will lead a `403 Forbidden`.
|
||||||
|
|
||||||
The Matrix Public Archive doesn't hold onto any data (it's
|
The Matrix Viewer hold onto any data (it's
|
||||||
stateless) and requests the messages from the homeserver every time. The
|
stateless) and requests the messages from the homeserver every time. The
|
||||||
[archive.matrix.org](https://archive.matrix.org/) instance has some caching in place, 5
|
[view.matrix.org](https://view.matrix.org/) instance has some caching in place, 5
|
||||||
minutes for the current day, and 2 days for past content.
|
minutes for the current day, and 2 days for past content.
|
||||||
|
|
||||||
See the [opt out
|
See the [opt out
|
||||||
|
@ -40,22 +43,21 @@ for more details.
|
||||||
|
|
||||||
Only Matrix rooms with `world_readable` [history
|
Only Matrix rooms with `world_readable` [history
|
||||||
visibility](https://spec.matrix.org/latest/client-server-api/#room-history-visibility)
|
visibility](https://spec.matrix.org/latest/client-server-api/#room-history-visibility)
|
||||||
are accessible in the Matrix Public Archive and indexed by search engines. One easy way
|
are accessible in the Matrix Viewer and indexed by search engines. One easy way
|
||||||
to opt-out is to change your rooms history visibility to something else if you don't
|
to opt-out is to change your rooms history visibility to something else if you don't
|
||||||
intend for your room be world readable.
|
intend for your room be world readable.
|
||||||
|
|
||||||
Dedicated opt-out controls are being tracked in
|
Dedicated opt-out controls are being tracked in
|
||||||
[#47](https://github.com/matrix-org/matrix-public-archive/issues/47).
|
[#47](https://github.com/matrix-org/matrix-viewer/issues/47).
|
||||||
|
|
||||||
As a workaround for [archive.matrix.org](https://archive.matrix.org/), you can ban the
|
As a workaround for [view.matrix.org](https://view.matrix.org/), you can ban the
|
||||||
`@archive:matrix.org` user if you don't want your room content to be shown in the
|
`@view:matrix.org` user if you don't want your room content to be shown at all.
|
||||||
archive at all.
|
|
||||||
|
|
||||||
### Why does the archive user join rooms instead peeking in the room or using guests?
|
### Why does the bot user join rooms instead peeking in the room or using guests?
|
||||||
|
|
||||||
Since the archive only displays rooms with `world_readable` history visibility, we could
|
Since Matrix Viewer only displays rooms with `world_readable` history visibility, we could
|
||||||
peek into the rooms without joining. This is being explored in
|
peek into the rooms without joining. This is being explored in
|
||||||
[#272](https://github.com/matrix-org/matrix-public-archive/pull/272). But peeking
|
[#272](https://github.com/matrix-org/matrix-viewer/pull/272). But peeking
|
||||||
doesn't work when the server doesn't know about the room already (this is commonly
|
doesn't work when the server doesn't know about the room already (this is commonly
|
||||||
referred to as federated peeking) which is why we have to fallback to joining the room
|
referred to as federated peeking) which is why we have to fallback to joining the room
|
||||||
in any case. We could solve the federated peeking problem and avoid the join with
|
in any case. We could solve the federated peeking problem and avoid the join with
|
||||||
|
@ -64,7 +66,7 @@ to check whether the room is `world_readable` even over federation.
|
||||||
|
|
||||||
Guests are completely separate concept and controlled by the `m.room.guest_access` state
|
Guests are completely separate concept and controlled by the `m.room.guest_access` state
|
||||||
event in the room. Guest access is also a much different ask than read-only access since
|
event in the room. Guest access is also a much different ask than read-only access since
|
||||||
guests can also send messages in the room which isn't always desirable. The archive bot
|
guests can also send messages in the room which isn't always desirable. The bot
|
||||||
is read-only and does not send messages.
|
is read-only and does not send messages.
|
||||||
|
|
||||||
## Technical details
|
## Technical details
|
||||||
|
@ -72,7 +74,7 @@ is read-only and does not send messages.
|
||||||
The main readme has a [technical overview](../README.md#technical-overview) of the
|
The main readme has a [technical overview](../README.md#technical-overview) of the
|
||||||
project. Here are a few more details.
|
project. Here are a few more details.
|
||||||
|
|
||||||
### How do I figure out what version of the Matrix Public Archive is running?
|
### How do I figure out what version of the Matrix Viewer is running?
|
||||||
|
|
||||||
Just visit the `/health-check` endpoint which will return information like the following:
|
Just visit the `/health-check` endpoint which will return information like the following:
|
||||||
|
|
||||||
|
@ -86,11 +88,11 @@ Just visit the `/health-check` endpoint which will return information like the f
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### How does the archive room URL relate to what is displayed on the page?
|
### How does the room URL relate to what is displayed on the page?
|
||||||
|
|
||||||
We start the end of the date/time specified in the URL looking backward up to the limit.
|
We start the end of the date/time specified in the URL looking backward up to the limit.
|
||||||
|
|
||||||
### Why does the time selector only appear for some pages?
|
### Why does the time selector only appear for some pages?
|
||||||
|
|
||||||
The time selector only appears for pages that have a lot of messages on a given
|
The time selector only appears for pages that have a lot of messages on a given
|
||||||
day/hour/minute/second (more than the configured `archiveMessageLimit`).
|
day/hour/minute/second (more than the configured `messageLimit`).
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
If you haven't setup `matrix-public-archive` yet, see the [_Setup_ section in the root `README.md`](../README.md#setup)
|
If you haven't setup `matrix-viewer` yet, see the [_Setup_ section in the root `README.md`](../README.md#setup)
|
||||||
|
|
||||||
Then we need to setup the federation cluster of homeservers that we will test with.
|
Then we need to setup the federation cluster of homeservers that we will test with.
|
||||||
Sorry, this isn't automated yet when you run the tests 🙇
|
Sorry, this isn't automated yet when you run the tests 🙇
|
||||||
|
@ -10,10 +10,10 @@ Sorry, this isn't automated yet when you run the tests 🙇
|
||||||
```sh
|
```sh
|
||||||
# Build the test homeserver image that are pre-configured to federate with each other
|
# Build the test homeserver image that are pre-configured to federate with each other
|
||||||
$ docker pull matrixdotorg/synapse:latest
|
$ docker pull matrixdotorg/synapse:latest
|
||||||
$ docker build -t matrix-public-archive-test-homeserver -f test/dockerfiles/Synapse.Dockerfile test/dockerfiles/
|
$ docker build -t matrix-viewer-test-homeserver -f test/dockerfiles/Synapse.Dockerfile test/dockerfiles/
|
||||||
|
|
||||||
# Start the test homeservers
|
# Start the test homeservers
|
||||||
$ docker-compose --project-name matrix_public_archive_test -f test/docker-compose.yml up -d --no-recreate
|
$ docker-compose --project-name matrix_viewer_test -f test/docker-compose.yml up -d --no-recreate
|
||||||
```
|
```
|
||||||
|
|
||||||
## Running the tests
|
## Running the tests
|
||||||
|
@ -22,7 +22,7 @@ $ docker-compose --project-name matrix_public_archive_test -f test/docker-compos
|
||||||
$ npm run test
|
$ npm run test
|
||||||
```
|
```
|
||||||
|
|
||||||
Or if you want to keep the Matrix Public Archive server running after the tests run and
|
Or if you want to keep the Matrix Viewer server running after the tests run and
|
||||||
explore the UI from the interactive URL's printed on the screen to better debug, use:
|
explore the UI from the interactive URL's printed on the screen to better debug, use:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
@ -30,7 +30,7 @@ $ npm run test-interactive
|
||||||
```
|
```
|
||||||
|
|
||||||
Caveat: You might not see the same result that a test is seeing when visiting the
|
Caveat: You might not see the same result that a test is seeing when visiting the
|
||||||
interactive URL. Some tests set config like the `archiveMessageLimit` which is reset
|
interactive URL. Some tests set config like the `messageLimit` which is reset
|
||||||
after each test case unless you are using `npm run test-interactive` and visiting the
|
after each test case unless you are using `npm run test-interactive` and visiting the
|
||||||
interactive URL for a failed test. Otherwise, we reset config between each test case so
|
interactive URL for a failed test. Otherwise, we reset config between each test case so
|
||||||
they don't leak and contaminate each other.
|
they don't leak and contaminate each other.
|
||||||
|
@ -41,9 +41,9 @@ Some copy-pasta to help you manage the Docker containers for the test homeserver
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ docker ps --all | grep test_hs
|
$ docker ps --all | grep test_hs
|
||||||
$ docker logs -f --tail 10 matrix_public_archive_test_hs1_1
|
$ docker logs -f --tail 10 matrix_viewer_test_hs1_1
|
||||||
$ docker logs -f --tail 10 matrix_public_archive_test_hs2_1
|
$ docker logs -f --tail 10 matrix_viewer_test_hs2_1
|
||||||
|
|
||||||
$ docker stop matrix_public_archive_test_hs1_1 matrix_public_archive_test_hs2_1
|
$ docker stop matrix_viewer_test_hs1_1 matrix_viewer_test_hs2_1
|
||||||
$ docker rm matrix_public_archive_test_hs1_1 matrix_public_archive_test_hs2_1
|
$ docker rm matrix_viewer_test_hs1_1 matrix_viewer_test_hs2_1
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
{
|
{
|
||||||
"name": "matrix-public-archive",
|
"name": "matrix-viewer",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "matrix-public-archive",
|
"name": "matrix-viewer",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
"hydrogen-view-sdk": "npm:@mlm/hydrogen-view-sdk@^0.28.0-scratch",
|
"hydrogen-view-sdk": "npm:@mlm/hydrogen-view-sdk@^0.28.0-scratch",
|
||||||
"json5": "^2.2.1",
|
"json5": "^2.2.1",
|
||||||
"linkedom": "^0.14.17",
|
"linkedom": "^0.14.17",
|
||||||
"matrix-public-archive-shared": "file:./shared/",
|
"matrix-viewer-shared": "file:./shared/",
|
||||||
"nconf": "^0.11.3",
|
"nconf": "^0.11.3",
|
||||||
"opentelemetry-instrumentation-fetch-node": "^1.0.0",
|
"opentelemetry-instrumentation-fetch-node": "^1.0.0",
|
||||||
"url-join": "^4.0.1"
|
"url-join": "^4.0.1"
|
||||||
|
@ -3706,7 +3706,7 @@
|
||||||
"url": "https://github.com/sponsors/sindresorhus"
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/matrix-public-archive-shared": {
|
"node_modules/matrix-viewer-shared": {
|
||||||
"resolved": "shared",
|
"resolved": "shared",
|
||||||
"link": true
|
"link": true
|
||||||
},
|
},
|
||||||
|
@ -7787,7 +7787,7 @@
|
||||||
"semver": "^6.0.0"
|
"semver": "^6.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"matrix-public-archive-shared": {
|
"matrix-viewer-shared": {
|
||||||
"version": "file:shared"
|
"version": "file:shared"
|
||||||
},
|
},
|
||||||
"media-typer": {
|
"media-typer": {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
{
|
{
|
||||||
"name": "matrix-public-archive",
|
"name": "matrix-viewer",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/matrix-org/matrix-public-archive"
|
"url": "https://github.com/matrix-org/matrix-viewer"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"lint": "eslint \"**/*.js\"",
|
"lint": "eslint \"**/*.js\"",
|
||||||
|
@ -53,7 +53,7 @@
|
||||||
"hydrogen-view-sdk": "npm:@mlm/hydrogen-view-sdk@^0.28.0-scratch",
|
"hydrogen-view-sdk": "npm:@mlm/hydrogen-view-sdk@^0.28.0-scratch",
|
||||||
"json5": "^2.2.1",
|
"json5": "^2.2.1",
|
||||||
"linkedom": "^0.14.17",
|
"linkedom": "^0.14.17",
|
||||||
"matrix-public-archive-shared": "file:./shared/",
|
"matrix-viewer-shared": "file:./shared/",
|
||||||
"nconf": "^0.11.3",
|
"nconf": "^0.11.3",
|
||||||
"opentelemetry-instrumentation-fetch-node": "^1.0.0",
|
"opentelemetry-instrumentation-fetch-node": "^1.0.0",
|
||||||
"url-join": "^4.0.1"
|
"url-join": "^4.0.1"
|
||||||
|
|
|
@ -96,7 +96,7 @@ async function _renderHydrogenToStringUnsafe(renderOptions) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define this for the SSR context
|
// Define this for the SSR context
|
||||||
dom.window.matrixPublicArchiveContext = {
|
dom.window.matrixViewerContext = {
|
||||||
...renderOptions.vmRenderContext,
|
...renderOptions.vmRenderContext,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ function getAssetUrls() {
|
||||||
_assetUrls = {
|
_assetUrls = {
|
||||||
faviconIco: getAssetUrl('client/img/favicon.ico'),
|
faviconIco: getAssetUrl('client/img/favicon.ico'),
|
||||||
faviconSvg: getAssetUrl('client/img/favicon.svg'),
|
faviconSvg: getAssetUrl('client/img/favicon.svg'),
|
||||||
opengraphImage: getAssetUrl('client/img/matrix-public-archive-opengraph.png'),
|
opengraphImage: getAssetUrl('client/img/opengraph.png'),
|
||||||
};
|
};
|
||||||
return _assetUrls;
|
return _assetUrls;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ function renderPageHtml({
|
||||||
|
|
||||||
// Serialize the state for when we run the Hydrogen render again client-side to
|
// Serialize the state for when we run the Hydrogen render again client-side to
|
||||||
// re-hydrate the DOM
|
// re-hydrate the DOM
|
||||||
const serializedMatrixPublicArchiveContext = JSON.stringify({
|
const serializedMatrixViewerContext = JSON.stringify({
|
||||||
...vmRenderContext,
|
...vmRenderContext,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ if (atEventId) {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/javascript" nonce="${pageOptions.cspNonce}">
|
<script type="text/javascript" nonce="${pageOptions.cspNonce}">
|
||||||
window.matrixPublicArchiveContext = ${safeJson(serializedMatrixPublicArchiveContext)}
|
window.matrixViewerContext = ${safeJson(serializedMatrixViewerContext)}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
${scripts
|
${scripts
|
||||||
|
|
|
@ -6,7 +6,7 @@ const urlJoin = require('url-join');
|
||||||
const StatusError = require('../errors/status-error');
|
const StatusError = require('../errors/status-error');
|
||||||
const { fetchEndpointAsJson } = require('../fetch-endpoint');
|
const { fetchEndpointAsJson } = require('../fetch-endpoint');
|
||||||
const getServerNameFromMatrixRoomIdOrAlias = require('./get-server-name-from-matrix-room-id-or-alias');
|
const getServerNameFromMatrixRoomIdOrAlias = require('./get-server-name-from-matrix-room-id-or-alias');
|
||||||
const MatrixPublicArchiveURLCreator = require('matrix-public-archive-shared/lib/url-creator');
|
const MatrixViewerURLCreator = require('matrix-viewer-shared/lib/url-creator');
|
||||||
|
|
||||||
const config = require('../config');
|
const config = require('../config');
|
||||||
const basePath = config.get('basePath');
|
const basePath = config.get('basePath');
|
||||||
|
@ -14,7 +14,7 @@ assert(basePath);
|
||||||
const matrixServerUrl = config.get('matrixServerUrl');
|
const matrixServerUrl = config.get('matrixServerUrl');
|
||||||
assert(matrixServerUrl);
|
assert(matrixServerUrl);
|
||||||
|
|
||||||
const matrixPublicArchiveURLCreator = new MatrixPublicArchiveURLCreator(basePath);
|
const matrixViewerURLCreator = new MatrixViewerURLCreator(basePath);
|
||||||
|
|
||||||
async function ensureRoomJoined(
|
async function ensureRoomJoined(
|
||||||
accessToken,
|
accessToken,
|
||||||
|
@ -52,9 +52,9 @@ async function ensureRoomJoined(
|
||||||
reason:
|
reason:
|
||||||
`Joining room to check history visibility. ` +
|
`Joining room to check history visibility. ` +
|
||||||
`If your room is public with shared or world readable history visibility, ` +
|
`If your room is public with shared or world readable history visibility, ` +
|
||||||
`it will be accessible on ${matrixPublicArchiveURLCreator.roomDirectoryUrl()}. ` +
|
`it will be accessible on ${matrixViewerURLCreator.roomDirectoryUrl()}. ` +
|
||||||
`See the FAQ for more details: ` +
|
`See the FAQ for more details: ` +
|
||||||
`https://github.com/matrix-org/matrix-public-archive/blob/main/docs/faq.md#why-did-the-archive-bot-join-my-room`,
|
`https://github.com/matrix-org/matrix-viewer/blob/main/docs/faq.md#why-did-the-bot-join-my-room`,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
assert(
|
assert(
|
||||||
|
@ -63,7 +63,7 @@ async function ensureRoomJoined(
|
||||||
);
|
);
|
||||||
return joinData.room_id;
|
return joinData.room_id;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw new StatusError(403, `Archiver is unable to join room: ${err.message}`);
|
throw new StatusError(403, `Bot is unable to join room: ${err.message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
const urlJoin = require('url-join');
|
const urlJoin = require('url-join');
|
||||||
const { DIRECTION } = require('matrix-public-archive-shared/lib/reference-values');
|
const { DIRECTION } = require('matrix-viewer-shared/lib/reference-values');
|
||||||
const { fetchEndpointAsJson } = require('../fetch-endpoint');
|
const { fetchEndpointAsJson } = require('../fetch-endpoint');
|
||||||
const { traceFunction } = require('../../tracing/trace-utilities');
|
const { traceFunction } = require('../../tracing/trace-utilities');
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ async function fetchAccessibleRooms(
|
||||||
const fetchedRoomsInDirection =
|
const fetchedRoomsInDirection =
|
||||||
direction === DIRECTION.forward ? fetchedRooms : fetchedRooms.reverse();
|
direction === DIRECTION.forward ? fetchedRooms : fetchedRooms.reverse();
|
||||||
|
|
||||||
// We only want to see world_readable rooms in the archive
|
// We only want to see world_readable rooms
|
||||||
let index = 0;
|
let index = 0;
|
||||||
for (let room of fetchedRoomsInDirection) {
|
for (let room of fetchedRoomsInDirection) {
|
||||||
if (room.world_readable) {
|
if (room.world_readable) {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const { traceFunction } = require('../../tracing/trace-utilities');
|
const { traceFunction } = require('../../tracing/trace-utilities');
|
||||||
|
|
||||||
const { DIRECTION } = require('matrix-public-archive-shared/lib/reference-values');
|
const { DIRECTION } = require('matrix-viewer-shared/lib/reference-values');
|
||||||
const timestampToEvent = require('./timestamp-to-event');
|
const timestampToEvent = require('./timestamp-to-event');
|
||||||
const getMessagesResponseFromEventId = require('./get-messages-response-from-event-id');
|
const getMessagesResponseFromEventId = require('./get-messages-response-from-event-id');
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const urlJoin = require('url-join');
|
const urlJoin = require('url-join');
|
||||||
|
|
||||||
const { DIRECTION } = require('matrix-public-archive-shared/lib/reference-values');
|
const { DIRECTION } = require('matrix-viewer-shared/lib/reference-values');
|
||||||
const { fetchEndpointAsJson } = require('../fetch-endpoint');
|
const { fetchEndpointAsJson } = require('../fetch-endpoint');
|
||||||
|
|
||||||
const config = require('../config');
|
const config = require('../config');
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
const { getUtcStartOfDayTs } = require('matrix-public-archive-shared/lib/timestamp-utilities');
|
const { getUtcStartOfDayTs } = require('matrix-viewer-shared/lib/timestamp-utilities');
|
||||||
|
|
||||||
// `X-Date-Temporal-Context` indicates the temporal context of the content, whether it
|
// `X-Date-Temporal-Context` indicates the temporal context of the content, whether it
|
||||||
// is related to past, present, or future *day*.
|
// is related to past, present, or future *day*.
|
||||||
|
|
|
@ -8,7 +8,7 @@ const basePath = config.get('basePath');
|
||||||
assert(basePath);
|
assert(basePath);
|
||||||
const {
|
const {
|
||||||
VALID_SIGIL_TO_ENTITY_DESCRIPTOR_MAP,
|
VALID_SIGIL_TO_ENTITY_DESCRIPTOR_MAP,
|
||||||
} = require('matrix-public-archive-shared/lib/reference-values');
|
} = require('matrix-viewer-shared/lib/reference-values');
|
||||||
|
|
||||||
// Create a regex string that will match a normal string or the URI encoded string or
|
// Create a regex string that will match a normal string or the URI encoded string or
|
||||||
// any combination of some characters being URI encoded. Only worries about characters
|
// any combination of some characters being URI encoded. Only worries about characters
|
||||||
|
@ -28,7 +28,7 @@ function uriEncodedMatrixCompatibleRegex(inputString) {
|
||||||
// - `/!xxx:my.synapse.server` -> `/roomid/xxx:my.synapse.server`
|
// - `/!xxx:my.synapse.server` -> `/roomid/xxx:my.synapse.server`
|
||||||
// - `/%23xxx%3Amy.synapse.server` -> `/r/xxx:my.synapse.server`
|
// - `/%23xxx%3Amy.synapse.server` -> `/r/xxx:my.synapse.server`
|
||||||
// - `/roomid/%23xxx%3Amy.synapse.server/date/2022/09/20?via=my.synapse.server` -> `/r/xxx:my.synapse.server/date/2022/09/20`
|
// - `/roomid/%23xxx%3Amy.synapse.server/date/2022/09/20?via=my.synapse.server` -> `/r/xxx:my.synapse.server/date/2022/09/20`
|
||||||
function redirectToCorrectArchiveUrlIfBadSigilMiddleware(req, res, next) {
|
function redirectToCorrectRoomUrlIfBadSigilMiddleware(req, res, next) {
|
||||||
// This could be with or with our without the sigil. Although the correct thing here
|
// This could be with or with our without the sigil. Although the correct thing here
|
||||||
// is to have no sigil. We will try to correct it for them in any case.
|
// is to have no sigil. We will try to correct it for them in any case.
|
||||||
const roomIdOrAliasDirty = req.params.roomIdOrAliasDirty;
|
const roomIdOrAliasDirty = req.params.roomIdOrAliasDirty;
|
||||||
|
@ -45,7 +45,7 @@ function redirectToCorrectArchiveUrlIfBadSigilMiddleware(req, res, next) {
|
||||||
const entityDescriptor = VALID_SIGIL_TO_ENTITY_DESCRIPTOR_MAP[sigil];
|
const entityDescriptor = VALID_SIGIL_TO_ENTITY_DESCRIPTOR_MAP[sigil];
|
||||||
if (!entityDescriptor) {
|
if (!entityDescriptor) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Unknown sigil=${sigil} has no entityDescriptor. This is an error with the Matrix Public Archive itself (please open an issue).`
|
`Unknown sigil=${sigil} has no entityDescriptor. This is an error with the Matrix Viewer itself (please open an issue).`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,4 +67,4 @@ function redirectToCorrectArchiveUrlIfBadSigilMiddleware(req, res, next) {
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = redirectToCorrectArchiveUrlIfBadSigilMiddleware;
|
module.exports = redirectToCorrectRoomUrlIfBadSigilMiddleware;
|
|
@ -83,7 +83,7 @@ async function timeoutMiddleware(req, res, next) {
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const pageOptions = {
|
const pageOptions = {
|
||||||
title: `Server timeout - Matrix Public Archive`,
|
title: `Server timeout - Matrix Viewer`,
|
||||||
description: `Unable to respond in time (${requestTimeoutMs / 1000}s)`,
|
description: `Unable to respond in time (${requestTimeoutMs / 1000}s)`,
|
||||||
entryPoint: 'client/js/entry-client-timeout.js',
|
entryPoint: 'client/js/entry-client-timeout.js',
|
||||||
locationUrl: urlJoin(basePath, req.originalUrl),
|
locationUrl: urlJoin(basePath, req.originalUrl),
|
||||||
|
@ -104,7 +104,7 @@ async function timeoutMiddleware(req, res, next) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// The most semantic HTTP status code to return here is a 504 Gateway timeout but if
|
// The most semantic HTTP status code to return here is a 504 Gateway timeout but if
|
||||||
// you use Cloudflare in front of the archive, it will serve its own
|
// you use Cloudflare in front of the viewer, it will serve its own
|
||||||
// Cloudflare-branded 504 page if your own origin server responds with a 504. And
|
// Cloudflare-branded 504 page if your own origin server responds with a 504. And
|
||||||
// the only way to disable this functionality is to have an Enterprise Cloudflare
|
// the only way to disable this functionality is to have an Enterprise Cloudflare
|
||||||
// plan. So to workaround this, we return a 500 instead. Relevant Cloudflare docs:
|
// plan. So to workaround this, we return a 500 instead. Relevant Cloudflare docs:
|
||||||
|
|
|
@ -14,7 +14,7 @@ assert(basePath);
|
||||||
// `/r/#room-alias:server/date/2022/10/27` -> `/r/room-alias:server/date/2022/10/27`
|
// `/r/#room-alias:server/date/2022/10/27` -> `/r/room-alias:server/date/2022/10/27`
|
||||||
function clientSideRoomAliasHashRedirectRoute(req, res) {
|
function clientSideRoomAliasHashRedirectRoute(req, res) {
|
||||||
const pageOptions = {
|
const pageOptions = {
|
||||||
title: `Page not found - Matrix Public Archive`,
|
title: `Page not found - Matrix Viewer`,
|
||||||
description: `This page does not exist but we may be able to redirect you to the right place.`,
|
description: `This page does not exist but we may be able to redirect you to the right place.`,
|
||||||
entryPoint: 'client/js/entry-client-room-alias-hash-redirect.js',
|
entryPoint: 'client/js/entry-client-room-alias-hash-redirect.js',
|
||||||
locationUrl: urlJoin(basePath, req.originalUrl),
|
locationUrl: urlJoin(basePath, req.originalUrl),
|
||||||
|
|
|
@ -12,7 +12,7 @@ const preventClickjackingMiddleware = require('../middleware/prevent-clickjackin
|
||||||
const contentSecurityPolicyMiddleware = require('../middleware/content-security-policy-middleware');
|
const contentSecurityPolicyMiddleware = require('../middleware/content-security-policy-middleware');
|
||||||
const identifyRoute = require('../middleware/identify-route-middleware');
|
const identifyRoute = require('../middleware/identify-route-middleware');
|
||||||
const clientSideRoomAliasHashRedirectRoute = require('./client-side-room-alias-hash-redirect-route');
|
const clientSideRoomAliasHashRedirectRoute = require('./client-side-room-alias-hash-redirect-route');
|
||||||
const redirectToCorrectArchiveUrlIfBadSigil = require('../middleware/redirect-to-correct-archive-url-if-bad-sigil-middleware');
|
const redirectToCorrectRoomUrlIfBadSigil = require('../middleware/redirect-to-correct-room-url-if-bad-sigil-middleware');
|
||||||
|
|
||||||
function installRoutes(app) {
|
function installRoutes(app) {
|
||||||
app.use(handleTracingMiddleware);
|
app.use(handleTracingMiddleware);
|
||||||
|
@ -43,11 +43,11 @@ function installRoutes(app) {
|
||||||
'/faq',
|
'/faq',
|
||||||
identifyRoute('faq'),
|
identifyRoute('faq'),
|
||||||
asyncHandler(async function (req, res) {
|
asyncHandler(async function (req, res) {
|
||||||
res.redirect('https://github.com/matrix-org/matrix-public-archive/blob/main/docs/faq.md');
|
res.redirect('https://github.com/matrix-org/matrix-viewer/blob/main/docs/faq.md');
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
// Our own archive app styles and scripts
|
// Our own viewer app styles and scripts
|
||||||
app.use('/assets', express.static(path.join(__dirname, '../../dist/assets')));
|
app.use('/assets', express.static(path.join(__dirname, '../../dist/assets')));
|
||||||
|
|
||||||
app.use('/', timeoutMiddleware, require('./room-directory-routes'));
|
app.use('/', timeoutMiddleware, require('./room-directory-routes'));
|
||||||
|
@ -72,8 +72,8 @@ function installRoutes(app) {
|
||||||
// redirect them to the correct URL without the sigil to the correct path above.
|
// redirect them to the correct URL without the sigil to the correct path above.
|
||||||
app.get(
|
app.get(
|
||||||
'/:roomIdOrAliasDirty',
|
'/:roomIdOrAliasDirty',
|
||||||
identifyRoute('redirect-to-correct-archive-url-if-bad-sigil'),
|
identifyRoute('redirect-to-correct-room-url-if-bad-sigil'),
|
||||||
redirectToCorrectArchiveUrlIfBadSigil
|
redirectToCorrectRoomUrlIfBadSigil
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ const urlJoin = require('url-join');
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const asyncHandler = require('../lib/express-async-handler');
|
const asyncHandler = require('../lib/express-async-handler');
|
||||||
|
|
||||||
const { DIRECTION } = require('matrix-public-archive-shared/lib/reference-values');
|
const { DIRECTION } = require('matrix-viewer-shared/lib/reference-values');
|
||||||
const RouteTimeoutAbortError = require('../lib/errors/route-timeout-abort-error');
|
const RouteTimeoutAbortError = require('../lib/errors/route-timeout-abort-error');
|
||||||
const UserClosedConnectionAbortError = require('../lib/errors/user-closed-connection-abort-error');
|
const UserClosedConnectionAbortError = require('../lib/errors/user-closed-connection-abort-error');
|
||||||
const identifyRoute = require('../middleware/identify-route-middleware');
|
const identifyRoute = require('../middleware/identify-route-middleware');
|
||||||
|
@ -86,7 +86,7 @@ router.get(
|
||||||
const shouldIndex = !stopSearchEngineIndexingFromConfig;
|
const shouldIndex = !stopSearchEngineIndexingFromConfig;
|
||||||
|
|
||||||
const pageOptions = {
|
const pageOptions = {
|
||||||
title: `Matrix Public Archive`,
|
title: `Matrix Viewer`,
|
||||||
description:
|
description:
|
||||||
'Browse thousands of rooms using Matrix. The new portal into the Matrix ecosystem.',
|
'Browse thousands of rooms using Matrix. The new portal into the Matrix ecosystem.',
|
||||||
entryPoint: 'client/js/entry-client-room-directory.js',
|
entryPoint: 'client/js/entry-client-room-directory.js',
|
||||||
|
|
|
@ -7,7 +7,7 @@ const express = require('express');
|
||||||
const asyncHandler = require('../lib/express-async-handler');
|
const asyncHandler = require('../lib/express-async-handler');
|
||||||
const StatusError = require('../lib/errors/status-error');
|
const StatusError = require('../lib/errors/status-error');
|
||||||
|
|
||||||
const redirectToCorrectArchiveUrlIfBadSigil = require('../middleware/redirect-to-correct-archive-url-if-bad-sigil-middleware');
|
const redirectToCorrectRoomUrlIfBadSigil = require('../middleware/redirect-to-correct-room-url-if-bad-sigil-middleware');
|
||||||
const identifyRoute = require('../middleware/identify-route-middleware');
|
const identifyRoute = require('../middleware/identify-route-middleware');
|
||||||
|
|
||||||
const { HTTPResponseError } = require('../lib/fetch-endpoint');
|
const { HTTPResponseError } = require('../lib/fetch-endpoint');
|
||||||
|
@ -25,15 +25,15 @@ const getMessagesResponseFromEventId = require('../lib/matrix-utils/get-messages
|
||||||
const renderHydrogenVmRenderScriptToPageHtml = require('../hydrogen-render/render-hydrogen-vm-render-script-to-page-html');
|
const renderHydrogenVmRenderScriptToPageHtml = require('../hydrogen-render/render-hydrogen-vm-render-script-to-page-html');
|
||||||
const setHeadersToPreloadAssets = require('../lib/set-headers-to-preload-assets');
|
const setHeadersToPreloadAssets = require('../lib/set-headers-to-preload-assets');
|
||||||
const setHeadersForDateTemporalContext = require('../lib/set-headers-for-date-temporal-context');
|
const setHeadersForDateTemporalContext = require('../lib/set-headers-for-date-temporal-context');
|
||||||
const MatrixPublicArchiveURLCreator = require('matrix-public-archive-shared/lib/url-creator');
|
const MatrixViewerURLCreator = require('matrix-viewer-shared/lib/url-creator');
|
||||||
const { mxcUrlToHttpThumbnail } = require('matrix-public-archive-shared/lib/mxc-url-to-http');
|
const { mxcUrlToHttpThumbnail } = require('matrix-viewer-shared/lib/mxc-url-to-http');
|
||||||
const checkTextForNsfw = require('matrix-public-archive-shared/lib/check-text-for-nsfw');
|
const checkTextForNsfw = require('matrix-viewer-shared/lib/check-text-for-nsfw');
|
||||||
const {
|
const {
|
||||||
MS_LOOKUP,
|
MS_LOOKUP,
|
||||||
TIME_PRECISION_VALUES,
|
TIME_PRECISION_VALUES,
|
||||||
DIRECTION,
|
DIRECTION,
|
||||||
VALID_ENTITY_DESCRIPTOR_TO_SIGIL_MAP,
|
VALID_ENTITY_DESCRIPTOR_TO_SIGIL_MAP,
|
||||||
} = require('matrix-public-archive-shared/lib/reference-values');
|
} = require('matrix-viewer-shared/lib/reference-values');
|
||||||
const { ONE_DAY_IN_MS, ONE_HOUR_IN_MS, ONE_MINUTE_IN_MS, ONE_SECOND_IN_MS } = MS_LOOKUP;
|
const { ONE_DAY_IN_MS, ONE_HOUR_IN_MS, ONE_MINUTE_IN_MS, ONE_SECOND_IN_MS } = MS_LOOKUP;
|
||||||
const {
|
const {
|
||||||
roundUpTimestampToUtcDay,
|
roundUpTimestampToUtcDay,
|
||||||
|
@ -48,7 +48,7 @@ const {
|
||||||
areTimestampsFromSameUtcHour,
|
areTimestampsFromSameUtcHour,
|
||||||
areTimestampsFromSameUtcMinute,
|
areTimestampsFromSameUtcMinute,
|
||||||
areTimestampsFromSameUtcSecond,
|
areTimestampsFromSameUtcSecond,
|
||||||
} = require('matrix-public-archive-shared/lib/timestamp-utilities');
|
} = require('matrix-viewer-shared/lib/timestamp-utilities');
|
||||||
|
|
||||||
const config = require('../lib/config');
|
const config = require('../lib/config');
|
||||||
const basePath = config.get('basePath');
|
const basePath = config.get('basePath');
|
||||||
|
@ -58,7 +58,7 @@ assert(matrixServerUrl);
|
||||||
const matrixAccessToken = config.get('matrixAccessToken');
|
const matrixAccessToken = config.get('matrixAccessToken');
|
||||||
assert(matrixAccessToken);
|
assert(matrixAccessToken);
|
||||||
|
|
||||||
const matrixPublicArchiveURLCreator = new MatrixPublicArchiveURLCreator(basePath);
|
const matrixViewerURLCreator = new MatrixViewerURLCreator(basePath);
|
||||||
|
|
||||||
const router = express.Router({
|
const router = express.Router({
|
||||||
caseSensitive: true,
|
caseSensitive: true,
|
||||||
|
@ -69,10 +69,10 @@ const router = express.Router({
|
||||||
const validSigilList = Object.values(VALID_ENTITY_DESCRIPTOR_TO_SIGIL_MAP);
|
const validSigilList = Object.values(VALID_ENTITY_DESCRIPTOR_TO_SIGIL_MAP);
|
||||||
const sigilRe = new RegExp(`^(${validSigilList.join('|')})`);
|
const sigilRe = new RegExp(`^(${validSigilList.join('|')})`);
|
||||||
|
|
||||||
function getErrorStringForTooManyMessages(archiveMessageLimit) {
|
function getErrorStringForTooManyMessages(messageLimit) {
|
||||||
const message =
|
const message =
|
||||||
`Too many messages were sent all within a second for us to display ` +
|
`Too many messages were sent all within a second for us to display ` +
|
||||||
`(more than ${archiveMessageLimit} in one second). We're unable to redirect you to ` +
|
`(more than ${messageLimit} in one second). We're unable to redirect you to ` +
|
||||||
`a smaller time range to view them without losing a few between each page. ` +
|
`a smaller time range to view them without losing a few between each page. ` +
|
||||||
`Since this is probably pretty rare, we've decided not to support it for now.`;
|
`Since this is probably pretty rare, we've decided not to support it for now.`;
|
||||||
return message;
|
return message;
|
||||||
|
@ -88,7 +88,7 @@ function getRoomIdOrAliasFromReq(req) {
|
||||||
const sigil = VALID_ENTITY_DESCRIPTOR_TO_SIGIL_MAP[entityDescriptor];
|
const sigil = VALID_ENTITY_DESCRIPTOR_TO_SIGIL_MAP[entityDescriptor];
|
||||||
if (!sigil) {
|
if (!sigil) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Unknown entityDescriptor=${entityDescriptor} has no sigil. This is an error with the Matrix Public Archive itself (please open an issue).`
|
`Unknown entityDescriptor=${entityDescriptor} has no sigil. This is an error with the Matrix Viewer itself (please open an issue).`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ function getRoomIdOrAliasFromReq(req) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line max-statements, complexity
|
// eslint-disable-next-line max-statements, complexity
|
||||||
function parseArchiveRangeFromReq(req) {
|
function parseDateTimeInfoFromReq(req) {
|
||||||
const yyyy = parseInt(req.params.yyyy, 10);
|
const yyyy = parseInt(req.params.yyyy, 10);
|
||||||
// Month is the only zero-based index in this group
|
// Month is the only zero-based index in this group
|
||||||
const mm = parseInt(req.params.mm, 10) - 1;
|
const mm = parseInt(req.params.mm, 10) - 1;
|
||||||
|
@ -165,11 +165,11 @@ function parseArchiveRangeFromReq(req) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
router.use(redirectToCorrectArchiveUrlIfBadSigil);
|
router.use(redirectToCorrectRoomUrlIfBadSigil);
|
||||||
|
|
||||||
router.get(
|
router.get(
|
||||||
'/',
|
'/',
|
||||||
identifyRoute('app-archive-room-index'),
|
identifyRoute('app-room-index'),
|
||||||
asyncHandler(async function (req, res) {
|
asyncHandler(async function (req, res) {
|
||||||
const roomIdOrAlias = getRoomIdOrAliasFromReq(req);
|
const roomIdOrAlias = getRoomIdOrAliasFromReq(req);
|
||||||
|
|
||||||
|
@ -199,7 +199,7 @@ router.get(
|
||||||
|
|
||||||
// Redirect to a day with messages
|
// Redirect to a day with messages
|
||||||
res.redirect(
|
res.redirect(
|
||||||
matrixPublicArchiveURLCreator.archiveUrlForDate(roomIdOrAlias, new Date(originServerTs), {
|
matrixViewerURLCreator.roomUrlForDate(roomIdOrAlias, new Date(originServerTs), {
|
||||||
// We can avoid passing along the `via` query parameter because we already
|
// We can avoid passing along the `via` query parameter because we already
|
||||||
// joined the room above (see `ensureRoomJoined`).
|
// joined the room above (see `ensureRoomJoined`).
|
||||||
//
|
//
|
||||||
|
@ -211,7 +211,7 @@ router.get(
|
||||||
|
|
||||||
router.get(
|
router.get(
|
||||||
'/event/:eventId',
|
'/event/:eventId',
|
||||||
identifyRoute('app-archive-room-event'),
|
identifyRoute('app-room-event'),
|
||||||
asyncHandler(async function (req, res) {
|
asyncHandler(async function (req, res) {
|
||||||
// TODO: Fetch event to get `origin_server_ts` and redirect to
|
// TODO: Fetch event to get `origin_server_ts` and redirect to
|
||||||
// /!roomId/2022/01/01?at=$eventId
|
// /!roomId/2022/01/01?at=$eventId
|
||||||
|
@ -221,7 +221,7 @@ router.get(
|
||||||
|
|
||||||
router.get(
|
router.get(
|
||||||
'/jump',
|
'/jump',
|
||||||
identifyRoute('app-archive-room-jump'),
|
identifyRoute('app-room-jump'),
|
||||||
// eslint-disable-next-line max-statements, complexity
|
// eslint-disable-next-line max-statements, complexity
|
||||||
asyncHandler(async function (req, res) {
|
asyncHandler(async function (req, res) {
|
||||||
const roomIdOrAlias = getRoomIdOrAliasFromReq(req);
|
const roomIdOrAlias = getRoomIdOrAliasFromReq(req);
|
||||||
|
@ -289,7 +289,7 @@ router.get(
|
||||||
try {
|
try {
|
||||||
// We pull this fresh from the config for each request to ensure we have an
|
// We pull this fresh from the config for each request to ensure we have an
|
||||||
// updated value between each e2e test
|
// updated value between each e2e test
|
||||||
const archiveMessageLimit = config.get('archiveMessageLimit');
|
const messageLimit = config.get('messageLimit');
|
||||||
|
|
||||||
let roomCreateEventId;
|
let roomCreateEventId;
|
||||||
// Find the closest event to the given timestamp
|
// Find the closest event to the given timestamp
|
||||||
|
@ -348,9 +348,9 @@ router.get(
|
||||||
// the next chunk in the desired direction.
|
// the next chunk in the desired direction.
|
||||||
// ==============================
|
// ==============================
|
||||||
//
|
//
|
||||||
// When jumping backwards, since a given room archive URL represents the end of
|
// When jumping backwards, since a given room URL represents the end of the
|
||||||
// the day/time-period looking backward (scroll is also anchored to the bottom),
|
// day/time-period looking backward (scroll is also anchored to the bottom), we
|
||||||
// we just need to move the user to the time-period just prior the current one.
|
// just need to move the user to the time-period just prior the current one.
|
||||||
//
|
//
|
||||||
// We are trying to avoid sending the user to the same time period they were just
|
// We are trying to avoid sending the user to the same time period they were just
|
||||||
// viewing. i.e, if they were visiting `/2020/01/02T16:00:00` (displays messages
|
// viewing. i.e, if they were visiting `/2020/01/02T16:00:00` (displays messages
|
||||||
|
@ -364,7 +364,7 @@ router.get(
|
||||||
// We choose `currentRangeStartTs` instead of `ts` (the jump point) because
|
// We choose `currentRangeStartTs` instead of `ts` (the jump point) because
|
||||||
// TODO: why? and we don't choose `currentRangeEndTs` because TODO: why? - I
|
// TODO: why? and we don't choose `currentRangeEndTs` because TODO: why? - I
|
||||||
// feel like I can't justify this, see
|
// feel like I can't justify this, see
|
||||||
// https://github.com/matrix-org/matrix-public-archive/pull/167#discussion_r1170850432
|
// https://github.com/matrix-org/matrix-viewer/pull/167#discussion_r1170850432
|
||||||
const fromSameDay =
|
const fromSameDay =
|
||||||
tsForClosestEvent && areTimestampsFromSameUtcDay(currentRangeStartTs, tsForClosestEvent);
|
tsForClosestEvent && areTimestampsFromSameUtcDay(currentRangeStartTs, tsForClosestEvent);
|
||||||
const fromSameHour =
|
const fromSameHour =
|
||||||
|
@ -414,7 +414,7 @@ router.get(
|
||||||
// We don't need to do anything. The next closest event is far enough away
|
// We don't need to do anything. The next closest event is far enough away
|
||||||
// (greater than 1 day) where we don't need to worry about the URL at all and
|
// (greater than 1 day) where we don't need to worry about the URL at all and
|
||||||
// can just render whatever day that the closest event is from because the
|
// can just render whatever day that the closest event is from because the
|
||||||
// archives biggest time-period represented in the URL is a day.
|
// viewers biggest time-period represented in the URL is a day.
|
||||||
//
|
//
|
||||||
// We can display more than a day of content at a given URL (imagine lots of a
|
// We can display more than a day of content at a given URL (imagine lots of a
|
||||||
// quiet days in a room), but the URL will never represent a time-period
|
// quiet days in a room), but the URL will never represent a time-period
|
||||||
|
@ -426,7 +426,7 @@ router.get(
|
||||||
}
|
}
|
||||||
// When jumping forwards, the goal is to go forward 100 messages, so that when we
|
// When jumping forwards, the goal is to go forward 100 messages, so that when we
|
||||||
// view the room at that point going backwards 100 messages (which is how the
|
// view the room at that point going backwards 100 messages (which is how the
|
||||||
// archive works for any given date from the archive URL), we end up at the
|
// viewer works for any given date from the viewer URL), we end up at the
|
||||||
// perfect continuation spot in the room (seamless).
|
// perfect continuation spot in the room (seamless).
|
||||||
//
|
//
|
||||||
// XXX: This is flawed in the fact that when we go `/messages?dir=b` later, it
|
// XXX: This is flawed in the fact that when we go `/messages?dir=b` later, it
|
||||||
|
@ -446,7 +446,7 @@ router.get(
|
||||||
roomId,
|
roomId,
|
||||||
eventId: eventIdForClosestEvent,
|
eventId: eventIdForClosestEvent,
|
||||||
dir: DIRECTION.forward,
|
dir: DIRECTION.forward,
|
||||||
limit: archiveMessageLimit,
|
limit: messageLimit,
|
||||||
abortSignal: req.abortSignal,
|
abortSignal: req.abortSignal,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -500,7 +500,7 @@ router.get(
|
||||||
|
|
||||||
// Back-track from the last message timestamp to the nearest date boundary.
|
// Back-track from the last message timestamp to the nearest date boundary.
|
||||||
// Because we're back-tracking a couple events here, when we paginate back out
|
// Because we're back-tracking a couple events here, when we paginate back out
|
||||||
// by the `archiveMessageLimit` later in the room route, it will gurantee some
|
// by the `messageLimit` later in the room route, it will gurantee some
|
||||||
// overlap with the previous page we jumped from so we don't lose any messages
|
// overlap with the previous page we jumped from so we don't lose any messages
|
||||||
// in the gap.
|
// in the gap.
|
||||||
//
|
//
|
||||||
|
@ -511,11 +511,11 @@ router.get(
|
||||||
// the same timestamp and we will lose messages in the gap because it displays
|
// the same timestamp and we will lose messages in the gap because it displays
|
||||||
// more than we thought.
|
// more than we thought.
|
||||||
//
|
//
|
||||||
// If the `/messages` response returns less than the `archiveMessageLimit`
|
// If the `/messages` response returns less than the `messageLimit`
|
||||||
// looking forwards, it means we're looking at the latest events in the room. We
|
// looking forwards, it means we're looking at the latest events in the room. We
|
||||||
// can simply just display the day that the latest event occured on or the given
|
// can simply just display the day that the latest event occured on or the given
|
||||||
// rangeEnd (whichever is later).
|
// rangeEnd (whichever is later).
|
||||||
const haveReachedLatestMessagesInRoom = messageResData.chunk?.length < archiveMessageLimit;
|
const haveReachedLatestMessagesInRoom = messageResData.chunk?.length < messageLimit;
|
||||||
if (haveReachedLatestMessagesInRoom) {
|
if (haveReachedLatestMessagesInRoom) {
|
||||||
const latestDesiredTs = Math.max(currentRangeEndTs, tsOfLastMessage);
|
const latestDesiredTs = Math.max(currentRangeEndTs, tsOfLastMessage);
|
||||||
const latestDesiredDate = new Date(latestDesiredTs);
|
const latestDesiredDate = new Date(latestDesiredTs);
|
||||||
|
@ -561,9 +561,7 @@ router.get(
|
||||||
// 501 Not Implemented: the server does not support the functionality required
|
// 501 Not Implemented: the server does not support the functionality required
|
||||||
// to fulfill the request
|
// to fulfill the request
|
||||||
res.status(501);
|
res.status(501);
|
||||||
res.send(
|
res.send(`/jump ran into a problem: ${getErrorStringForTooManyMessages(messageLimit)}`);
|
||||||
`/jump ran into a problem: ${getErrorStringForTooManyMessages(archiveMessageLimit)}`
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -661,7 +659,7 @@ router.get(
|
||||||
// Since we're going backwards, we already know where to go so we can navigate
|
// Since we're going backwards, we already know where to go so we can navigate
|
||||||
// straight there.
|
// straight there.
|
||||||
res.redirect(
|
res.redirect(
|
||||||
matrixPublicArchiveURLCreator.archiveUrlForDate(
|
matrixViewerURLCreator.roomUrlForDate(
|
||||||
predecessorRoomId,
|
predecessorRoomId,
|
||||||
// XXX: We should probably go fetch and use the timestamp from
|
// XXX: We should probably go fetch and use the timestamp from
|
||||||
// `predecessorLastKnownEventId` here but that requires an extra
|
// `predecessorLastKnownEventId` here but that requires an extra
|
||||||
|
@ -688,7 +686,7 @@ router.get(
|
||||||
if (successorRoomId) {
|
if (successorRoomId) {
|
||||||
// Jump to the successor room and continue at the first event of the room
|
// Jump to the successor room and continue at the first event of the room
|
||||||
res.redirect(
|
res.redirect(
|
||||||
matrixPublicArchiveURLCreator.archiveJumpUrlForRoom(successorRoomId, {
|
matrixViewerURLCreator.jumpUrlForRoom(successorRoomId, {
|
||||||
dir: DIRECTION.forward,
|
dir: DIRECTION.forward,
|
||||||
currentRangeStartTs: 0,
|
currentRangeStartTs: 0,
|
||||||
currentRangeEndTs: 0,
|
currentRangeEndTs: 0,
|
||||||
|
@ -731,7 +729,7 @@ router.get(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Redirect to a day with messages
|
// Redirect to a day with messages
|
||||||
const archiveUrlToRedirecTo = matrixPublicArchiveURLCreator.archiveUrlForDate(
|
const urlToRedirecTo = matrixViewerURLCreator.roomUrlForDate(
|
||||||
roomIdOrAlias,
|
roomIdOrAlias,
|
||||||
new Date(newOriginServerTs),
|
new Date(newOriginServerTs),
|
||||||
{
|
{
|
||||||
|
@ -740,7 +738,7 @@ router.get(
|
||||||
preferredPrecision,
|
preferredPrecision,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
res.redirect(archiveUrlToRedirecTo);
|
res.redirect(urlToRedirecTo);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -750,7 +748,7 @@ router.get(
|
||||||
// `path-to-regex` bug where the `?` wasn't attaching to the capture group, see
|
// `path-to-regex` bug where the `?` wasn't attaching to the capture group, see
|
||||||
// https://github.com/pillarjs/path-to-regexp/issues/287
|
// https://github.com/pillarjs/path-to-regexp/issues/287
|
||||||
'/date/:yyyy(\\d{4})/:mm(\\d{2})/:dd(\\d{2}):time(T\\d\\d?:\\d\\d?((:\\d\\d?)?))?',
|
'/date/:yyyy(\\d{4})/:mm(\\d{2})/:dd(\\d{2}):time(T\\d\\d?:\\d\\d?((:\\d\\d?)?))?',
|
||||||
identifyRoute('app-archive-room-date'),
|
identifyRoute('app-room-date'),
|
||||||
// eslint-disable-next-line max-statements, complexity
|
// eslint-disable-next-line max-statements, complexity
|
||||||
asyncHandler(async function (req, res) {
|
asyncHandler(async function (req, res) {
|
||||||
const nowTs = Date.now();
|
const nowTs = Date.now();
|
||||||
|
@ -758,16 +756,16 @@ router.get(
|
||||||
|
|
||||||
// We pull this fresh from the config for each request to ensure we have an
|
// We pull this fresh from the config for each request to ensure we have an
|
||||||
// updated value between each e2e test
|
// updated value between each e2e test
|
||||||
const archiveMessageLimit = config.get('archiveMessageLimit');
|
const messageLimit = config.get('messageLimit');
|
||||||
assert(archiveMessageLimit);
|
assert(messageLimit);
|
||||||
// Synapse has a max `/messages` limit of 1000
|
// Synapse has a max `/messages` limit of 1000
|
||||||
assert(
|
assert(
|
||||||
archiveMessageLimit <= 999,
|
messageLimit <= 999,
|
||||||
'archiveMessageLimit needs to be in range [1, 999]. We can only get 1000 messages at a time from Synapse and we need a buffer of at least one to see if there are too many messages on a given day so you can only configure a max of 999. If you need more messages, we will have to implement pagination'
|
'messageLimit needs to be in range [1, 999]. We can only get 1000 messages at a time from Synapse and we need a buffer of at least one to see if there are too many messages on a given day so you can only configure a max of 999. If you need more messages, we will have to implement pagination'
|
||||||
);
|
);
|
||||||
|
|
||||||
const { toTimestamp, yyyy, mm, dd, timeDefined, secondsDefined } =
|
const { toTimestamp, yyyy, mm, dd, timeDefined, secondsDefined } =
|
||||||
parseArchiveRangeFromReq(req);
|
parseDateTimeInfoFromReq(req);
|
||||||
|
|
||||||
let precisionFromUrl = TIME_PRECISION_VALUES.none;
|
let precisionFromUrl = TIME_PRECISION_VALUES.none;
|
||||||
if (secondsDefined) {
|
if (secondsDefined) {
|
||||||
|
@ -795,7 +793,7 @@ router.get(
|
||||||
// this for all places we `ensureRoomJoined`). But we need the `roomId` for use with
|
// this for all places we `ensureRoomJoined`). But we need the `roomId` for use with
|
||||||
// the various Matrix API's anyway and `/join/{roomIdOrAlias}` -> `{ room_id }` is a
|
// the various Matrix API's anyway and `/join/{roomIdOrAlias}` -> `{ room_id }` is a
|
||||||
// great way to get it (see
|
// great way to get it (see
|
||||||
// https://github.com/matrix-org/matrix-public-archive/issues/50).
|
// https://github.com/matrix-org/matrix-viewer/issues/50).
|
||||||
const viaServers = parseViaServersFromUserInput(req.query.via);
|
const viaServers = parseViaServersFromUserInput(req.query.via);
|
||||||
const roomId = await ensureRoomJoined(matrixAccessToken, roomIdOrAlias, {
|
const roomId = await ensureRoomJoined(matrixAccessToken, roomIdOrAlias, {
|
||||||
viaServers,
|
viaServers,
|
||||||
|
@ -803,7 +801,7 @@ router.get(
|
||||||
});
|
});
|
||||||
|
|
||||||
// Do these in parallel to avoid the extra time in sequential round-trips
|
// Do these in parallel to avoid the extra time in sequential round-trips
|
||||||
// (we want to display the archive page faster)
|
// (we want to display the page faster)
|
||||||
const [roomData, { events, stateEventMap }] = await Promise.all([
|
const [roomData, { events, stateEventMap }] = await Promise.all([
|
||||||
fetchRoomData(matrixAccessToken, roomId, { abortSignal: req.abortSignal }),
|
fetchRoomData(matrixAccessToken, roomId, { abortSignal: req.abortSignal }),
|
||||||
// We over-fetch messages outside of the range of the given day so that we
|
// We over-fetch messages outside of the range of the given day so that we
|
||||||
|
@ -816,24 +814,24 @@ router.get(
|
||||||
accessToken: matrixAccessToken,
|
accessToken: matrixAccessToken,
|
||||||
roomId,
|
roomId,
|
||||||
ts: toTimestamp,
|
ts: toTimestamp,
|
||||||
// We fetch one more than the `archiveMessageLimit` so that we can see if there
|
// We fetch one more than the `messageLimit` so that we can see if there
|
||||||
// are too many messages from the given day. If we have over the
|
// are too many messages from the given day. If we have over the
|
||||||
// `archiveMessageLimit` number of messages fetching from the given day, it's
|
// `messageLimit` number of messages fetching from the given day, it's
|
||||||
// acceptable to have them be from surrounding days. But if all 500 messages
|
// acceptable to have them be from surrounding days. But if all 500 messages
|
||||||
// (for example) are from the same day, let's redirect to a smaller hour range
|
// (for example) are from the same day, let's redirect to a smaller hour range
|
||||||
// to display.
|
// to display.
|
||||||
limit: archiveMessageLimit + 1,
|
limit: messageLimit + 1,
|
||||||
abortSignal: req.abortSignal,
|
abortSignal: req.abortSignal,
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Only `world_readable` rooms are viewable in the archive
|
// Only `world_readable` rooms are viewable
|
||||||
const allowedToViewRoom = roomData.historyVisibility === 'world_readable';
|
const allowedToViewRoom = roomData.historyVisibility === 'world_readable';
|
||||||
|
|
||||||
if (!allowedToViewRoom) {
|
if (!allowedToViewRoom) {
|
||||||
throw new StatusError(
|
throw new StatusError(
|
||||||
403,
|
403,
|
||||||
`Only \`world_readable\` rooms can be viewed in the archive. ` +
|
`Only \`world_readable\` rooms can be viewed with Matrix Viewer. ` +
|
||||||
`${roomData.id} has m.room.history_visiblity=${roomData.historyVisibility} ` +
|
`${roomData.id} has m.room.history_visiblity=${roomData.historyVisibility} ` +
|
||||||
`(set by ${roomData.historyVisibilityEventMeta?.sender} on ` +
|
`(set by ${roomData.historyVisibilityEventMeta?.sender} on ` +
|
||||||
`${new Date(roomData.historyVisibilityEventMeta?.originServerTs).toISOString()})`
|
`${new Date(roomData.historyVisibilityEventMeta?.originServerTs).toISOString()})`
|
||||||
|
@ -848,15 +846,11 @@ router.get(
|
||||||
if (hasNavigatedBeforeStartOfRoom && roomData.predecessorRoomId) {
|
if (hasNavigatedBeforeStartOfRoom && roomData.predecessorRoomId) {
|
||||||
// Jump to the predecessor room at the date/time the user is trying to visit at
|
// Jump to the predecessor room at the date/time the user is trying to visit at
|
||||||
res.redirect(
|
res.redirect(
|
||||||
matrixPublicArchiveURLCreator.archiveUrlForDate(
|
matrixViewerURLCreator.roomUrlForDate(roomData.predecessorRoomId, new Date(toTimestamp), {
|
||||||
roomData.predecessorRoomId,
|
|
||||||
new Date(toTimestamp),
|
|
||||||
{
|
|
||||||
preferredPrecision: precisionFromUrl,
|
preferredPrecision: precisionFromUrl,
|
||||||
// XXX: Should we also try combining `viaServers` we used to get to this room?
|
// XXX: Should we also try combining `viaServers` we used to get to this room?
|
||||||
viaServers: Array.from(roomData.predecessorViaServers || []),
|
viaServers: Array.from(roomData.predecessorViaServers || []),
|
||||||
}
|
})
|
||||||
)
|
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -876,15 +870,11 @@ router.get(
|
||||||
if (roomData.successorRoomId && isNavigatedPastSuccessor && !isNewestEventFromSameDay) {
|
if (roomData.successorRoomId && isNavigatedPastSuccessor && !isNewestEventFromSameDay) {
|
||||||
// Jump to the successor room at the date/time the user is trying to visit at
|
// Jump to the successor room at the date/time the user is trying to visit at
|
||||||
res.redirect(
|
res.redirect(
|
||||||
matrixPublicArchiveURLCreator.archiveUrlForDate(
|
matrixViewerURLCreator.roomUrlForDate(roomData.successorRoomId, new Date(toTimestamp), {
|
||||||
roomData.successorRoomId,
|
|
||||||
new Date(toTimestamp),
|
|
||||||
{
|
|
||||||
preferredPrecision: precisionFromUrl,
|
preferredPrecision: precisionFromUrl,
|
||||||
// Just try to pass on the `viaServers` the user was using to get to this room
|
// Just try to pass on the `viaServers` the user was using to get to this room
|
||||||
viaServers: Array.from(viaServers || []),
|
viaServers: Array.from(viaServers || []),
|
||||||
}
|
})
|
||||||
)
|
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -906,8 +896,8 @@ router.get(
|
||||||
);
|
);
|
||||||
|
|
||||||
const pageOptions = {
|
const pageOptions = {
|
||||||
title: `${roomData.name} - Matrix Public Archive`,
|
title: `${roomData.name} - Matrix Viewer`,
|
||||||
description: `View the history of the ${roomData.name} room in the Matrix Public Archive`,
|
description: `View the history of the ${roomData.name} room in the Matrix Viewer`,
|
||||||
imageUrl:
|
imageUrl:
|
||||||
roomData.avatarUrl &&
|
roomData.avatarUrl &&
|
||||||
mxcUrlToHttpThumbnail({
|
mxcUrlToHttpThumbnail({
|
||||||
|
@ -918,7 +908,7 @@ router.get(
|
||||||
blockedBySafeSearch: isNsfw,
|
blockedBySafeSearch: isNsfw,
|
||||||
entryPoint: 'client/js/entry-client-hydrogen.js',
|
entryPoint: 'client/js/entry-client-hydrogen.js',
|
||||||
locationUrl: urlJoin(basePath, req.originalUrl),
|
locationUrl: urlJoin(basePath, req.originalUrl),
|
||||||
canonicalUrl: matrixPublicArchiveURLCreator.archiveUrlForDate(
|
canonicalUrl: matrixViewerURLCreator.roomUrlForDate(
|
||||||
roomData.canonicalAlias || roomIdOrAlias,
|
roomData.canonicalAlias || roomIdOrAlias,
|
||||||
new Date(toTimestamp),
|
new Date(toTimestamp),
|
||||||
{
|
{
|
||||||
|
@ -954,7 +944,7 @@ router.get(
|
||||||
config: {
|
config: {
|
||||||
basePath,
|
basePath,
|
||||||
matrixServerUrl,
|
matrixServerUrl,
|
||||||
archiveMessageLimit,
|
messageLimit,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
abortSignal: req.abortSignal,
|
abortSignal: req.abortSignal,
|
||||||
|
|
|
@ -3,35 +3,35 @@
|
||||||
// Isomorphic script that runs in the browser and on the server for SSR (needs
|
// Isomorphic script that runs in the browser and on the server for SSR (needs
|
||||||
// browser context) that renders Hydrogen to the `document.body`.
|
// browser context) that renders Hydrogen to the `document.body`.
|
||||||
//
|
//
|
||||||
// Data is passed in via `window.matrixPublicArchiveContext`
|
// Data is passed in via `window.matrixViewerContext`
|
||||||
|
|
||||||
const assert = require('matrix-public-archive-shared/lib/assert');
|
const assert = require('matrix-viewer-shared/lib/assert');
|
||||||
const { Platform, MediaRepository, createNavigation, createRouter } = require('hydrogen-view-sdk');
|
const { Platform, MediaRepository, createNavigation, createRouter } = require('hydrogen-view-sdk');
|
||||||
|
|
||||||
const { TIME_PRECISION_VALUES } = require('matrix-public-archive-shared/lib/reference-values');
|
const { TIME_PRECISION_VALUES } = require('matrix-viewer-shared/lib/reference-values');
|
||||||
const ArchiveRoomView = require('matrix-public-archive-shared/views/ArchiveRoomView');
|
const RoomView = require('matrix-viewer-shared/views/RoomView');
|
||||||
const ArchiveHistory = require('matrix-public-archive-shared/lib/archive-history');
|
const MatrixViewerHistory = require('matrix-viewer-shared/lib/matrix-viewer-history');
|
||||||
const supressBlankAnchorsReloadingThePage = require('matrix-public-archive-shared/lib/supress-blank-anchors-reloading-the-page');
|
const supressBlankAnchorsReloadingThePage = require('matrix-viewer-shared/lib/supress-blank-anchors-reloading-the-page');
|
||||||
const ArchiveRoomViewModel = require('matrix-public-archive-shared/viewmodels/ArchiveRoomViewModel');
|
const RoomViewModel = require('matrix-viewer-shared/viewmodels/RoomViewModel');
|
||||||
const stubPowerLevelsObservable = require('matrix-public-archive-shared/lib/stub-powerlevels-observable');
|
const stubPowerLevelsObservable = require('matrix-viewer-shared/lib/stub-powerlevels-observable');
|
||||||
|
|
||||||
const toTimestamp = window.matrixPublicArchiveContext.toTimestamp;
|
const toTimestamp = window.matrixViewerContext.toTimestamp;
|
||||||
assert(toTimestamp);
|
assert(toTimestamp);
|
||||||
const precisionFromUrl = window.matrixPublicArchiveContext.precisionFromUrl;
|
const precisionFromUrl = window.matrixViewerContext.precisionFromUrl;
|
||||||
assert(Object.values(TIME_PRECISION_VALUES).includes(precisionFromUrl));
|
assert(Object.values(TIME_PRECISION_VALUES).includes(precisionFromUrl));
|
||||||
const roomData = window.matrixPublicArchiveContext.roomData;
|
const roomData = window.matrixViewerContext.roomData;
|
||||||
assert(roomData);
|
assert(roomData);
|
||||||
const events = window.matrixPublicArchiveContext.events;
|
const events = window.matrixViewerContext.events;
|
||||||
assert(events);
|
assert(events);
|
||||||
const stateEventMap = window.matrixPublicArchiveContext.stateEventMap;
|
const stateEventMap = window.matrixViewerContext.stateEventMap;
|
||||||
assert(stateEventMap);
|
assert(stateEventMap);
|
||||||
const shouldIndex = window.matrixPublicArchiveContext.shouldIndex;
|
const shouldIndex = window.matrixViewerContext.shouldIndex;
|
||||||
assert(shouldIndex !== undefined);
|
assert(shouldIndex !== undefined);
|
||||||
const config = window.matrixPublicArchiveContext.config;
|
const config = window.matrixViewerContext.config;
|
||||||
assert(config);
|
assert(config);
|
||||||
assert(config.matrixServerUrl);
|
assert(config.matrixServerUrl);
|
||||||
assert(config.basePath);
|
assert(config.basePath);
|
||||||
assert(config.archiveMessageLimit);
|
assert(config.messageLimit);
|
||||||
|
|
||||||
function addSupportClasses() {
|
function addSupportClasses() {
|
||||||
const input = document.createElement('input');
|
const input = document.createElement('input');
|
||||||
|
@ -65,7 +65,7 @@ async function mountHydrogen() {
|
||||||
const navigation = createNavigation();
|
const navigation = createNavigation();
|
||||||
platform.setNavigation(navigation);
|
platform.setNavigation(navigation);
|
||||||
|
|
||||||
const archiveHistory = new ArchiveHistory(
|
const matrixViewerHistory = new MatrixViewerHistory(
|
||||||
// We just have to match what Hydrogen is doing here.
|
// We just have to match what Hydrogen is doing here.
|
||||||
`#/session/123/room/${encodeURIComponent(roomData.id)}`
|
`#/session/123/room/${encodeURIComponent(roomData.id)}`
|
||||||
);
|
);
|
||||||
|
@ -75,7 +75,7 @@ async function mountHydrogen() {
|
||||||
// room and not include the session/room.
|
// room and not include the session/room.
|
||||||
//
|
//
|
||||||
// Normally, people use `history: platform.history,`
|
// Normally, people use `history: platform.history,`
|
||||||
history: archiveHistory,
|
history: matrixViewerHistory,
|
||||||
});
|
});
|
||||||
// Make it listen to changes from the history instance. And populate the
|
// Make it listen to changes from the history instance. And populate the
|
||||||
// `Navigation` with path segments to work from so `href`'s rendered on the
|
// `Navigation` with path segments to work from so `href`'s rendered on the
|
||||||
|
@ -101,15 +101,15 @@ async function mountHydrogen() {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const archiveRoomViewModel = new ArchiveRoomViewModel({
|
const roomViewModel = new RoomViewModel({
|
||||||
// Hydrogen options
|
// Hydrogen options
|
||||||
platform: platform,
|
platform: platform,
|
||||||
navigation: navigation,
|
navigation: navigation,
|
||||||
urlRouter: urlRouter,
|
urlRouter: urlRouter,
|
||||||
history: archiveHistory,
|
history: matrixViewerHistory,
|
||||||
// Our options
|
// Our options
|
||||||
homeserverUrl: config.matrixServerUrl,
|
homeserverUrl: config.matrixServerUrl,
|
||||||
archiveMessageLimit: config.archiveMessageLimit,
|
messageLimit: config.messageLimit,
|
||||||
room,
|
room,
|
||||||
// The timestamp from the URL that was originally visited
|
// The timestamp from the URL that was originally visited
|
||||||
dayTimestampTo: toTimestamp,
|
dayTimestampTo: toTimestamp,
|
||||||
|
@ -126,7 +126,7 @@ async function mountHydrogen() {
|
||||||
// ---------------------------------------------------------------------
|
// ---------------------------------------------------------------------
|
||||||
|
|
||||||
// Render what we actually care about
|
// Render what we actually care about
|
||||||
const view = new ArchiveRoomView(archiveRoomViewModel);
|
const view = new RoomView(roomViewModel);
|
||||||
appElement.replaceChildren(view.mount());
|
appElement.replaceChildren(view.mount());
|
||||||
|
|
||||||
addSupportClasses();
|
addSupportClasses();
|
||||||
|
|
|
@ -4,16 +4,16 @@
|
||||||
|
|
||||||
const { tileClassForEntry, viewClassForTile } = require('hydrogen-view-sdk');
|
const { tileClassForEntry, viewClassForTile } = require('hydrogen-view-sdk');
|
||||||
|
|
||||||
const JumpToPreviousActivitySummaryTileViewModel = require('matrix-public-archive-shared/viewmodels/JumpToPreviousActivitySummaryTileViewModel');
|
const JumpToPreviousActivitySummaryTileViewModel = require('matrix-viewer-shared/viewmodels/JumpToPreviousActivitySummaryTileViewModel');
|
||||||
const JumpToPreviousActivitySummaryTileView = require('matrix-public-archive-shared/views/JumpToPreviousActivitySummaryTileView');
|
const JumpToPreviousActivitySummaryTileView = require('matrix-viewer-shared/views/JumpToPreviousActivitySummaryTileView');
|
||||||
const JumpToNextActivitySummaryTileViewModel = require('matrix-public-archive-shared/viewmodels/JumpToNextActivitySummaryTileViewModel');
|
const JumpToNextActivitySummaryTileViewModel = require('matrix-viewer-shared/viewmodels/JumpToNextActivitySummaryTileViewModel');
|
||||||
const JumpToNextActivitySummaryTileView = require('matrix-public-archive-shared/views/JumpToNextActivitySummaryTileView');
|
const JumpToNextActivitySummaryTileView = require('matrix-viewer-shared/views/JumpToNextActivitySummaryTileView');
|
||||||
|
|
||||||
function customTileClassForEntry(entry) {
|
function customTileClassForEntry(entry) {
|
||||||
switch (entry.eventType) {
|
switch (entry.eventType) {
|
||||||
case 'org.matrix.archive.jump_to_previous_activity_summary':
|
case 'org.matrix.viewer.jump_to_previous_activity_summary':
|
||||||
return JumpToPreviousActivitySummaryTileViewModel;
|
return JumpToPreviousActivitySummaryTileViewModel;
|
||||||
case 'org.matrix.archive.jump_to_next_activity_summary':
|
case 'org.matrix.viewer.jump_to_next_activity_summary':
|
||||||
return JumpToNextActivitySummaryTileViewModel;
|
return JumpToNextActivitySummaryTileViewModel;
|
||||||
default:
|
default:
|
||||||
return tileClassForEntry(entry);
|
return tileClassForEntry(entry);
|
||||||
|
@ -22,9 +22,9 @@ function customTileClassForEntry(entry) {
|
||||||
|
|
||||||
function customViewClassForTile(vm) {
|
function customViewClassForTile(vm) {
|
||||||
switch (vm.shape) {
|
switch (vm.shape) {
|
||||||
case 'org.matrix.archive.jump_to_previous_activity_summary:shape':
|
case 'org.matrix.viewer.jump_to_previous_activity_summary:shape':
|
||||||
return JumpToPreviousActivitySummaryTileView;
|
return JumpToPreviousActivitySummaryTileView;
|
||||||
case 'org.matrix.archive.jump_to_next_activity_summary:shape':
|
case 'org.matrix.viewer.jump_to_next_activity_summary:shape':
|
||||||
return JumpToNextActivitySummaryTileView;
|
return JumpToNextActivitySummaryTileView;
|
||||||
default:
|
default:
|
||||||
return viewClassForTile(vm);
|
return viewClassForTile(vm);
|
||||||
|
|
|
@ -6,7 +6,7 @@ const assert = require('./assert');
|
||||||
// Mock a full hash whenever someone asks via `history.get()` but when
|
// Mock a full hash whenever someone asks via `history.get()` but when
|
||||||
// constructing URL's for use `href` etc, they should relative to the room
|
// constructing URL's for use `href` etc, they should relative to the room
|
||||||
// (remove session and room from the hash).
|
// (remove session and room from the hash).
|
||||||
class ArchiveHistory extends History {
|
class MatrixViewerHistory extends History {
|
||||||
constructor(baseHash) {
|
constructor(baseHash) {
|
||||||
assert(baseHash);
|
assert(baseHash);
|
||||||
super();
|
super();
|
||||||
|
@ -34,7 +34,7 @@ class ArchiveHistory extends History {
|
||||||
replacingUrl = url;
|
replacingUrl = url;
|
||||||
}
|
}
|
||||||
// Hydrogen hash routing: This is the sign that Hydrogen is navigating back to the
|
// Hydrogen hash routing: This is the sign that Hydrogen is navigating back to the
|
||||||
// root. Because of our custom archive logic, the `#` is removed before it gets
|
// root. Because of our custom Matrix Viewer logic, the `#` is removed before it gets
|
||||||
// here. But we just want to make sure the hash gets cleared out while maintaining
|
// here. But we just want to make sure the hash gets cleared out while maintaining
|
||||||
// our path and query parameters.
|
// our path and query parameters.
|
||||||
//
|
//
|
||||||
|
@ -60,7 +60,7 @@ class ArchiveHistory extends History {
|
||||||
replacingUrl = url;
|
replacingUrl = url;
|
||||||
}
|
}
|
||||||
// Hydrogen hash routing: This is the sign that Hydrogen is navigating back to the
|
// Hydrogen hash routing: This is the sign that Hydrogen is navigating back to the
|
||||||
// root. Because of our custom archive logic, the `#` is removed before it gets
|
// root. Because of our custom Matrix Viewer logic, the `#` is removed before it gets
|
||||||
// here. But we just want to make sure the hash gets cleared out while maintaining
|
// here. But we just want to make sure the hash gets cleared out while maintaining
|
||||||
// our path and query parameters.
|
// our path and query parameters.
|
||||||
//
|
//
|
||||||
|
@ -94,4 +94,4 @@ class ArchiveHistory extends History {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = ArchiveHistory;
|
module.exports = MatrixViewerHistory;
|
|
@ -6,14 +6,14 @@
|
||||||
const BASIC_ROOM_ALIAS_REGEX = /^(#(?:[^/:]+):(?:[^/]+))/;
|
const BASIC_ROOM_ALIAS_REGEX = /^(#(?:[^/:]+):(?:[^/]+))/;
|
||||||
|
|
||||||
// Returns `true` if redirecting, otherwise `false`
|
// Returns `true` if redirecting, otherwise `false`
|
||||||
function redirectIfRoomAliasInHash(matrixPublicArchiveURLCreator, redirectCallback) {
|
function redirectIfRoomAliasInHash(matrixViewerURLCreator, redirectCallback) {
|
||||||
function handleHashChange() {
|
function handleHashChange() {
|
||||||
const pageHash = window.location.hash;
|
const pageHash = window.location.hash;
|
||||||
|
|
||||||
const match = pageHash.match(BASIC_ROOM_ALIAS_REGEX);
|
const match = pageHash.match(BASIC_ROOM_ALIAS_REGEX);
|
||||||
if (match) {
|
if (match) {
|
||||||
const roomAlias = match[0];
|
const roomAlias = match[0];
|
||||||
const newLocation = matrixPublicArchiveURLCreator.archiveUrlForRoom(roomAlias);
|
const newLocation = matrixViewerURLCreator.roomUrl(roomAlias);
|
||||||
console.log(`Saw room alias in hash, redirecting to newLocation=${newLocation}`);
|
console.log(`Saw room alias in hash, redirecting to newLocation=${newLocation}`);
|
||||||
window.location = newLocation;
|
window.location = newLocation;
|
||||||
if (redirectCallback) {
|
if (redirectCallback) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const assert = require('matrix-public-archive-shared/lib/assert');
|
const assert = require('matrix-viewer-shared/lib/assert');
|
||||||
const { MS_LOOKUP } = require('matrix-public-archive-shared/lib/reference-values');
|
const { MS_LOOKUP } = require('matrix-viewer-shared/lib/reference-values');
|
||||||
const { ONE_DAY_IN_MS, ONE_HOUR_IN_MS, ONE_MINUTE_IN_MS, ONE_SECOND_IN_MS } = MS_LOOKUP;
|
const { ONE_DAY_IN_MS, ONE_HOUR_IN_MS, ONE_MINUTE_IN_MS, ONE_SECOND_IN_MS } = MS_LOOKUP;
|
||||||
|
|
||||||
function roundUpTimestampToUtcDay(ts) {
|
function roundUpTimestampToUtcDay(ts) {
|
||||||
|
|
|
@ -2,11 +2,8 @@
|
||||||
|
|
||||||
const urlJoin = require('url-join');
|
const urlJoin = require('url-join');
|
||||||
|
|
||||||
const assert = require('matrix-public-archive-shared/lib/assert');
|
const assert = require('matrix-viewer-shared/lib/assert');
|
||||||
const {
|
const { DIRECTION, TIME_PRECISION_VALUES } = require('matrix-viewer-shared/lib/reference-values');
|
||||||
DIRECTION,
|
|
||||||
TIME_PRECISION_VALUES,
|
|
||||||
} = require('matrix-public-archive-shared/lib/reference-values');
|
|
||||||
|
|
||||||
function qsToUrlPiece(qs) {
|
function qsToUrlPiece(qs) {
|
||||||
if (qs.toString()) {
|
if (qs.toString()) {
|
||||||
|
@ -55,7 +52,7 @@ class URLCreator {
|
||||||
return `${this._basePath}${qsToUrlPiece(qs)}`;
|
return `${this._basePath}${qsToUrlPiece(qs)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
_getArchiveUrlPathForRoomIdOrAlias(roomIdOrAlias) {
|
_getUrlPathForRoomIdOrAlias(roomIdOrAlias) {
|
||||||
let urlPath;
|
let urlPath;
|
||||||
// We don't `encodeURIComponent(...)` because the URL looks nicer without encoded things
|
// We don't `encodeURIComponent(...)` because the URL looks nicer without encoded things
|
||||||
if (roomIdOrAlias.startsWith('#')) {
|
if (roomIdOrAlias.startsWith('#')) {
|
||||||
|
@ -64,14 +61,14 @@ class URLCreator {
|
||||||
urlPath = `/roomid/${roomIdOrAlias.replace(/^!/, '')}`;
|
urlPath = `/roomid/${roomIdOrAlias.replace(/^!/, '')}`;
|
||||||
} else {
|
} else {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'URLCreator._getArchiveUrlPathForRoomIdOrAlias(...): roomIdOrAlias should start with # (alias) or ! (room ID)'
|
'URLCreator._getUrlPathForRoomIdOrAlias(...): roomIdOrAlias should start with # (alias) or ! (room ID)'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return urlPath;
|
return urlPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
archiveUrlForRoom(roomIdOrAlias, { viaServers = [] } = {}) {
|
roomUrl(roomIdOrAlias, { viaServers = [] } = {}) {
|
||||||
assert(roomIdOrAlias);
|
assert(roomIdOrAlias);
|
||||||
assert(Array.isArray(viaServers));
|
assert(Array.isArray(viaServers));
|
||||||
let qs = new URLSearchParams();
|
let qs = new URLSearchParams();
|
||||||
|
@ -79,12 +76,12 @@ class URLCreator {
|
||||||
qs.append('via', viaServer);
|
qs.append('via', viaServer);
|
||||||
});
|
});
|
||||||
|
|
||||||
const urlPath = this._getArchiveUrlPathForRoomIdOrAlias(roomIdOrAlias);
|
const urlPath = this._getUrlPathForRoomIdOrAlias(roomIdOrAlias);
|
||||||
|
|
||||||
return `${urlJoin(this._basePath, `${urlPath}`)}${qsToUrlPiece(qs)}`;
|
return `${urlJoin(this._basePath, `${urlPath}`)}${qsToUrlPiece(qs)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
archiveUrlForDate(
|
roomUrlForDate(
|
||||||
roomIdOrAlias,
|
roomIdOrAlias,
|
||||||
date,
|
date,
|
||||||
{ preferredPrecision = null, viaServers = [], scrollStartEventId } = {}
|
{ preferredPrecision = null, viaServers = [], scrollStartEventId } = {}
|
||||||
|
@ -110,7 +107,7 @@ class URLCreator {
|
||||||
qs.append('at', scrollStartEventId);
|
qs.append('at', scrollStartEventId);
|
||||||
}
|
}
|
||||||
|
|
||||||
const urlPath = this._getArchiveUrlPathForRoomIdOrAlias(roomIdOrAlias);
|
const urlPath = this._getUrlPathForRoomIdOrAlias(roomIdOrAlias);
|
||||||
|
|
||||||
// Gives the date in YYYY/mm/dd format.
|
// Gives the date in YYYY/mm/dd format.
|
||||||
// date.toISOString() -> 2022-02-16T23:20:04.709Z
|
// date.toISOString() -> 2022-02-16T23:20:04.709Z
|
||||||
|
@ -134,7 +131,7 @@ class URLCreator {
|
||||||
)}${qsToUrlPiece(qs)}`;
|
)}${qsToUrlPiece(qs)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
archiveJumpUrlForRoom(
|
jumpUrlForRoom(
|
||||||
roomIdOrAlias,
|
roomIdOrAlias,
|
||||||
{
|
{
|
||||||
dir,
|
dir,
|
||||||
|
@ -168,7 +165,7 @@ class URLCreator {
|
||||||
qs.append('via', viaServer);
|
qs.append('via', viaServer);
|
||||||
});
|
});
|
||||||
|
|
||||||
const urlPath = this._getArchiveUrlPathForRoomIdOrAlias(roomIdOrAlias);
|
const urlPath = this._getUrlPathForRoomIdOrAlias(roomIdOrAlias);
|
||||||
|
|
||||||
return `${urlJoin(this._basePath, `${urlPath}/jump`)}${qsToUrlPiece(qs)}`;
|
return `${urlJoin(this._basePath, `${urlPath}/jump`)}${qsToUrlPiece(qs)}`;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,38 +3,38 @@
|
||||||
// Isomorphic script that runs in the browser and on the server for SSR (needs
|
// Isomorphic script that runs in the browser and on the server for SSR (needs
|
||||||
// browser context) that renders Hydrogen to the `document.body`.
|
// browser context) that renders Hydrogen to the `document.body`.
|
||||||
//
|
//
|
||||||
// Data is passed in via `window.matrixPublicArchiveContext`
|
// Data is passed in via `window.matrixViewerContext`
|
||||||
|
|
||||||
const assert = require('matrix-public-archive-shared/lib/assert');
|
const assert = require('matrix-viewer-shared/lib/assert');
|
||||||
const { Platform, Navigation, createRouter } = require('hydrogen-view-sdk');
|
const { Platform, Navigation, createRouter } = require('hydrogen-view-sdk');
|
||||||
|
|
||||||
const MatrixPublicArchiveURLCreator = require('matrix-public-archive-shared/lib/url-creator');
|
const MatrixViewerURLCreator = require('matrix-viewer-shared/lib/url-creator');
|
||||||
const ArchiveHistory = require('matrix-public-archive-shared/lib/archive-history');
|
const MatrixViewerHistory = require('matrix-viewer-shared/lib/matrix-viewer-history');
|
||||||
const supressBlankAnchorsReloadingThePage = require('matrix-public-archive-shared/lib/supress-blank-anchors-reloading-the-page');
|
const supressBlankAnchorsReloadingThePage = require('matrix-viewer-shared/lib/supress-blank-anchors-reloading-the-page');
|
||||||
const redirectIfRoomAliasInHash = require('matrix-public-archive-shared/lib/redirect-if-room-alias-in-hash');
|
const redirectIfRoomAliasInHash = require('matrix-viewer-shared/lib/redirect-if-room-alias-in-hash');
|
||||||
|
|
||||||
const RoomDirectoryView = require('matrix-public-archive-shared/views/RoomDirectoryView');
|
const RoomDirectoryView = require('matrix-viewer-shared/views/RoomDirectoryView');
|
||||||
const RoomDirectoryViewModel = require('matrix-public-archive-shared/viewmodels/RoomDirectoryViewModel');
|
const RoomDirectoryViewModel = require('matrix-viewer-shared/viewmodels/RoomDirectoryViewModel');
|
||||||
|
|
||||||
const rooms = window.matrixPublicArchiveContext.rooms;
|
const rooms = window.matrixViewerContext.rooms;
|
||||||
assert(rooms);
|
assert(rooms);
|
||||||
const roomFetchError = window.matrixPublicArchiveContext.roomFetchError;
|
const roomFetchError = window.matrixViewerContext.roomFetchError;
|
||||||
const nextPaginationToken = window.matrixPublicArchiveContext.nextPaginationToken;
|
const nextPaginationToken = window.matrixViewerContext.nextPaginationToken;
|
||||||
const prevPaginationToken = window.matrixPublicArchiveContext.prevPaginationToken;
|
const prevPaginationToken = window.matrixViewerContext.prevPaginationToken;
|
||||||
const pageSearchParameters = window.matrixPublicArchiveContext.pageSearchParameters;
|
const pageSearchParameters = window.matrixViewerContext.pageSearchParameters;
|
||||||
const config = window.matrixPublicArchiveContext.config;
|
const config = window.matrixViewerContext.config;
|
||||||
assert(config);
|
assert(config);
|
||||||
assert(config.matrixServerUrl);
|
assert(config.matrixServerUrl);
|
||||||
assert(config.matrixServerName);
|
assert(config.matrixServerName);
|
||||||
assert(config.basePath);
|
assert(config.basePath);
|
||||||
|
|
||||||
const matrixPublicArchiveURLCreator = new MatrixPublicArchiveURLCreator(config.basePath);
|
const matrixViewerURLCreator = new MatrixViewerURLCreator(config.basePath);
|
||||||
|
|
||||||
supressBlankAnchorsReloadingThePage();
|
supressBlankAnchorsReloadingThePage();
|
||||||
|
|
||||||
let roomDirectoryViewModel;
|
let roomDirectoryViewModel;
|
||||||
let isRedirecting = false;
|
let isRedirecting = false;
|
||||||
isRedirecting = redirectIfRoomAliasInHash(matrixPublicArchiveURLCreator, () => {
|
isRedirecting = redirectIfRoomAliasInHash(matrixViewerURLCreator, () => {
|
||||||
isRedirecting = true;
|
isRedirecting = true;
|
||||||
if (roomDirectoryViewModel) {
|
if (roomDirectoryViewModel) {
|
||||||
roomDirectoryViewModel.setPageRedirectingFromUrlHash(true);
|
roomDirectoryViewModel.setPageRedirectingFromUrlHash(true);
|
||||||
|
@ -69,10 +69,10 @@ async function mountHydrogen() {
|
||||||
const navigation = new Navigation(allowsChild);
|
const navigation = new Navigation(allowsChild);
|
||||||
platform.setNavigation(navigation);
|
platform.setNavigation(navigation);
|
||||||
|
|
||||||
const archiveHistory = new ArchiveHistory(`#`);
|
const matrixViewerHistory = new MatrixViewerHistory(`#`);
|
||||||
const urlRouter = createRouter({
|
const urlRouter = createRouter({
|
||||||
navigation,
|
navigation,
|
||||||
history: archiveHistory,
|
history: matrixViewerHistory,
|
||||||
});
|
});
|
||||||
// Make it listen to changes from the history instance. And populate the
|
// Make it listen to changes from the history instance. And populate the
|
||||||
// `Navigation` with path segments to work from so `href`'s rendered on the
|
// `Navigation` with path segments to work from so `href`'s rendered on the
|
||||||
|
@ -83,12 +83,12 @@ async function mountHydrogen() {
|
||||||
// Hydrogen options
|
// Hydrogen options
|
||||||
navigation: navigation,
|
navigation: navigation,
|
||||||
urlRouter: urlRouter,
|
urlRouter: urlRouter,
|
||||||
history: archiveHistory,
|
history: matrixViewerHistory,
|
||||||
// Our options
|
// Our options
|
||||||
basePath: config.basePath,
|
basePath: config.basePath,
|
||||||
homeserverUrl: config.matrixServerUrl,
|
homeserverUrl: config.matrixServerUrl,
|
||||||
homeserverName: config.matrixServerName,
|
homeserverName: config.matrixServerName,
|
||||||
matrixPublicArchiveURLCreator,
|
matrixViewerURLCreator,
|
||||||
rooms,
|
rooms,
|
||||||
roomFetchError,
|
roomFetchError,
|
||||||
pageSearchParameters,
|
pageSearchParameters,
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
const { ViewModel, avatarInitials, getIdentifierColorNumber } = require('hydrogen-view-sdk');
|
const { ViewModel, avatarInitials, getIdentifierColorNumber } = require('hydrogen-view-sdk');
|
||||||
|
|
||||||
const assert = require('matrix-public-archive-shared/lib/assert');
|
const assert = require('matrix-viewer-shared/lib/assert');
|
||||||
const { mxcUrlToHttpThumbnail } = require('matrix-public-archive-shared/lib/mxc-url-to-http');
|
const { mxcUrlToHttpThumbnail } = require('matrix-viewer-shared/lib/mxc-url-to-http');
|
||||||
|
|
||||||
class AvatarViewModel extends ViewModel {
|
class AvatarViewModel extends ViewModel {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
|
|
|
@ -2,23 +2,23 @@
|
||||||
|
|
||||||
const { ViewModel } = require('hydrogen-view-sdk');
|
const { ViewModel } = require('hydrogen-view-sdk');
|
||||||
|
|
||||||
const assert = require('matrix-public-archive-shared/lib/assert');
|
const assert = require('matrix-viewer-shared/lib/assert');
|
||||||
|
|
||||||
class CalendarViewModel extends ViewModel {
|
class CalendarViewModel extends ViewModel {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
super(options);
|
super(options);
|
||||||
const { activeDate, calendarDate, room, matrixPublicArchiveURLCreator } = options;
|
const { activeDate, calendarDate, room, matrixViewerURLCreator } = options;
|
||||||
assert(activeDate);
|
assert(activeDate);
|
||||||
assert(calendarDate);
|
assert(calendarDate);
|
||||||
assert(room);
|
assert(room);
|
||||||
assert(matrixPublicArchiveURLCreator);
|
assert(matrixViewerURLCreator);
|
||||||
|
|
||||||
// The day being shown in the archive
|
// The day being shown
|
||||||
this._activeDate = activeDate;
|
this._activeDate = activeDate;
|
||||||
// The month displayed in the calendar
|
// The month displayed in the calendar
|
||||||
this._calendarDate = calendarDate;
|
this._calendarDate = calendarDate;
|
||||||
this._room = room;
|
this._room = room;
|
||||||
this._matrixPublicArchiveURLCreator = matrixPublicArchiveURLCreator;
|
this._matrixViewerURLCreator = matrixViewerURLCreator;
|
||||||
}
|
}
|
||||||
|
|
||||||
get activeDate() {
|
get activeDate() {
|
||||||
|
@ -37,8 +37,8 @@ class CalendarViewModel extends ViewModel {
|
||||||
this.emitChange('calendarDate');
|
this.emitChange('calendarDate');
|
||||||
}
|
}
|
||||||
|
|
||||||
archiveUrlForDate(date) {
|
roomUrlForDate(date) {
|
||||||
return this._matrixPublicArchiveURLCreator.archiveUrlForDate(
|
return this._matrixViewerURLCreator.roomUrlForDate(
|
||||||
this._room.canonicalAlias || this._room.id,
|
this._room.canonicalAlias || this._room.id,
|
||||||
date
|
date
|
||||||
);
|
);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
const { ViewModel } = require('hydrogen-view-sdk');
|
const { ViewModel } = require('hydrogen-view-sdk');
|
||||||
|
|
||||||
const LOCAL_STORAGE_KEYS = require('matrix-public-archive-shared/lib/local-storage-keys');
|
const LOCAL_STORAGE_KEYS = require('matrix-viewer-shared/lib/local-storage-keys');
|
||||||
|
|
||||||
class DeveloperOptionsContentViewModel extends ViewModel {
|
class DeveloperOptionsContentViewModel extends ViewModel {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
const { SimpleTile } = require('hydrogen-view-sdk');
|
const { SimpleTile } = require('hydrogen-view-sdk');
|
||||||
|
|
||||||
const { DIRECTION } = require('matrix-public-archive-shared/lib/reference-values');
|
const { DIRECTION } = require('matrix-viewer-shared/lib/reference-values');
|
||||||
const MatrixPublicArchiveURLCreator = require('matrix-public-archive-shared/lib/url-creator');
|
const MatrixViewerURLCreator = require('matrix-viewer-shared/lib/url-creator');
|
||||||
const assert = require('../lib/assert');
|
const assert = require('../lib/assert');
|
||||||
|
|
||||||
class JumpToNextActivitySummaryTileViewModel extends SimpleTile {
|
class JumpToNextActivitySummaryTileViewModel extends SimpleTile {
|
||||||
|
@ -13,11 +13,11 @@ class JumpToNextActivitySummaryTileViewModel extends SimpleTile {
|
||||||
|
|
||||||
const basePath = this._entry?.content?.['basePath'];
|
const basePath = this._entry?.content?.['basePath'];
|
||||||
assert(basePath);
|
assert(basePath);
|
||||||
this._matrixPublicArchiveURLCreator = new MatrixPublicArchiveURLCreator(basePath);
|
this._matrixViewerURLCreator = new MatrixViewerURLCreator(basePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
get shape() {
|
get shape() {
|
||||||
return 'org.matrix.archive.jump_to_next_activity_summary:shape';
|
return 'org.matrix.viewer.jump_to_next_activity_summary:shape';
|
||||||
}
|
}
|
||||||
|
|
||||||
get daySummaryKind() {
|
get daySummaryKind() {
|
||||||
|
@ -49,7 +49,7 @@ class JumpToNextActivitySummaryTileViewModel extends SimpleTile {
|
||||||
}
|
}
|
||||||
|
|
||||||
get jumpToNextActivityUrl() {
|
get jumpToNextActivityUrl() {
|
||||||
return this._matrixPublicArchiveURLCreator.archiveJumpUrlForRoom(
|
return this._matrixViewerURLCreator.jumpUrlForRoom(
|
||||||
this._entry?.content?.['canonicalAlias'] || this._entry.roomId,
|
this._entry?.content?.['canonicalAlias'] || this._entry.roomId,
|
||||||
{
|
{
|
||||||
dir: DIRECTION.forward,
|
dir: DIRECTION.forward,
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
const { SimpleTile } = require('hydrogen-view-sdk');
|
const { SimpleTile } = require('hydrogen-view-sdk');
|
||||||
|
|
||||||
const { DIRECTION } = require('matrix-public-archive-shared/lib/reference-values');
|
const { DIRECTION } = require('matrix-viewer-shared/lib/reference-values');
|
||||||
const MatrixPublicArchiveURLCreator = require('matrix-public-archive-shared/lib/url-creator');
|
const MatrixViewerURLCreator = require('matrix-viewer-shared/lib/url-creator');
|
||||||
const assert = require('../lib/assert');
|
const assert = require('../lib/assert');
|
||||||
|
|
||||||
class JumpToPreviousActivitySummaryTileViewModel extends SimpleTile {
|
class JumpToPreviousActivitySummaryTileViewModel extends SimpleTile {
|
||||||
|
@ -13,11 +13,11 @@ class JumpToPreviousActivitySummaryTileViewModel extends SimpleTile {
|
||||||
|
|
||||||
const basePath = this._entry?.content?.['basePath'];
|
const basePath = this._entry?.content?.['basePath'];
|
||||||
assert(basePath);
|
assert(basePath);
|
||||||
this._matrixPublicArchiveURLCreator = new MatrixPublicArchiveURLCreator(basePath);
|
this._matrixViewerURLCreator = new MatrixViewerURLCreator(basePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
get shape() {
|
get shape() {
|
||||||
return 'org.matrix.archive.jump_to_previous_activity_summary:shape';
|
return 'org.matrix.viewer.jump_to_previous_activity_summary:shape';
|
||||||
}
|
}
|
||||||
|
|
||||||
// The start of the range to use as a jumping off point to the previous activity
|
// The start of the range to use as a jumping off point to the previous activity
|
||||||
|
@ -41,7 +41,7 @@ class JumpToPreviousActivitySummaryTileViewModel extends SimpleTile {
|
||||||
}
|
}
|
||||||
|
|
||||||
get jumpToPreviousActivityUrl() {
|
get jumpToPreviousActivityUrl() {
|
||||||
return this._matrixPublicArchiveURLCreator.archiveJumpUrlForRoom(
|
return this._matrixViewerURLCreator.jumpUrlForRoom(
|
||||||
this._entry?.content?.['canonicalAlias'] || this._entry.roomId,
|
this._entry?.content?.['canonicalAlias'] || this._entry.roomId,
|
||||||
{
|
{
|
||||||
dir: DIRECTION.backward,
|
dir: DIRECTION.backward,
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
const { ViewModel } = require('hydrogen-view-sdk');
|
const { ViewModel } = require('hydrogen-view-sdk');
|
||||||
|
|
||||||
const assert = require('matrix-public-archive-shared/lib/assert');
|
const assert = require('matrix-viewer-shared/lib/assert');
|
||||||
const MatrixPublicArchiveURLCreator = require('matrix-public-archive-shared/lib/url-creator');
|
const MatrixViewerURLCreator = require('matrix-viewer-shared/lib/url-creator');
|
||||||
|
|
||||||
class RoomCardViewModel extends ViewModel {
|
class RoomCardViewModel extends ViewModel {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
|
@ -14,7 +14,7 @@ class RoomCardViewModel extends ViewModel {
|
||||||
assert(homeserverUrlToPullMediaFrom);
|
assert(homeserverUrlToPullMediaFrom);
|
||||||
assert(viaServers);
|
assert(viaServers);
|
||||||
|
|
||||||
this._matrixPublicArchiveURLCreator = new MatrixPublicArchiveURLCreator(basePath);
|
this._matrixViewerURLCreator = new MatrixViewerURLCreator(basePath);
|
||||||
|
|
||||||
this._roomId = room.room_id;
|
this._roomId = room.room_id;
|
||||||
this._canonicalAlias = room.canonical_alias;
|
this._canonicalAlias = room.canonical_alias;
|
||||||
|
@ -57,14 +57,11 @@ class RoomCardViewModel extends ViewModel {
|
||||||
return this._topic;
|
return this._topic;
|
||||||
}
|
}
|
||||||
|
|
||||||
get archiveRoomUrl() {
|
get roomUrl() {
|
||||||
return this._matrixPublicArchiveURLCreator.archiveUrlForRoom(
|
return this._matrixViewerURLCreator.roomUrl(this._canonicalAlias || this._roomId, {
|
||||||
this._canonicalAlias || this._roomId,
|
|
||||||
{
|
|
||||||
// Only include via servers when we have to fallback to the room ID
|
// Only include via servers when we have to fallback to the room ID
|
||||||
viaServers: this._canonicalAlias ? undefined : this._viaServers,
|
viaServers: this._canonicalAlias ? undefined : this._viaServers,
|
||||||
}
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get blockedBySafeSearch() {
|
get blockedBySafeSearch() {
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
|
|
||||||
const { ViewModel, ObservableMap, ApplyMap } = require('hydrogen-view-sdk');
|
const { ViewModel, ObservableMap, ApplyMap } = require('hydrogen-view-sdk');
|
||||||
|
|
||||||
const assert = require('matrix-public-archive-shared/lib/assert');
|
const assert = require('matrix-viewer-shared/lib/assert');
|
||||||
|
|
||||||
const LOCAL_STORAGE_KEYS = require('matrix-public-archive-shared/lib/local-storage-keys');
|
const LOCAL_STORAGE_KEYS = require('matrix-viewer-shared/lib/local-storage-keys');
|
||||||
const ModalViewModel = require('matrix-public-archive-shared/viewmodels/ModalViewModel');
|
const ModalViewModel = require('matrix-viewer-shared/viewmodels/ModalViewModel');
|
||||||
const HomeserverSelectionModalContentViewModel = require('matrix-public-archive-shared/viewmodels/HomeserverSelectionModalContentViewModel');
|
const HomeserverSelectionModalContentViewModel = require('matrix-viewer-shared/viewmodels/HomeserverSelectionModalContentViewModel');
|
||||||
const RoomCardViewModel = require('matrix-public-archive-shared/viewmodels/RoomCardViewModel');
|
const RoomCardViewModel = require('matrix-viewer-shared/viewmodels/RoomCardViewModel');
|
||||||
const checkTextForNsfw = require('matrix-public-archive-shared/lib/check-text-for-nsfw');
|
const checkTextForNsfw = require('matrix-viewer-shared/lib/check-text-for-nsfw');
|
||||||
const { DIRECTION } = require('../lib/reference-values');
|
const { DIRECTION } = require('../lib/reference-values');
|
||||||
|
|
||||||
const DEFAULT_SERVER_LIST = ['matrix.org', 'gitter.im'];
|
const DEFAULT_SERVER_LIST = ['matrix.org', 'gitter.im'];
|
||||||
|
@ -20,7 +20,7 @@ class RoomDirectoryViewModel extends ViewModel {
|
||||||
basePath,
|
basePath,
|
||||||
homeserverUrl,
|
homeserverUrl,
|
||||||
homeserverName,
|
homeserverName,
|
||||||
matrixPublicArchiveURLCreator,
|
matrixViewerURLCreator,
|
||||||
rooms,
|
rooms,
|
||||||
roomFetchError,
|
roomFetchError,
|
||||||
pageSearchParameters,
|
pageSearchParameters,
|
||||||
|
@ -30,14 +30,14 @@ class RoomDirectoryViewModel extends ViewModel {
|
||||||
assert(basePath);
|
assert(basePath);
|
||||||
assert(homeserverUrl);
|
assert(homeserverUrl);
|
||||||
assert(homeserverName);
|
assert(homeserverName);
|
||||||
assert(matrixPublicArchiveURLCreator);
|
assert(matrixViewerURLCreator);
|
||||||
assert(rooms);
|
assert(rooms);
|
||||||
|
|
||||||
this._roomFetchError = roomFetchError;
|
this._roomFetchError = roomFetchError;
|
||||||
|
|
||||||
this._homeserverUrl = homeserverUrl;
|
this._homeserverUrl = homeserverUrl;
|
||||||
this._homeserverName = homeserverName;
|
this._homeserverName = homeserverName;
|
||||||
this._matrixPublicArchiveURLCreator = matrixPublicArchiveURLCreator;
|
this._matrixViewerURLCreator = matrixViewerURLCreator;
|
||||||
|
|
||||||
this._isPageRedirectingFromUrlHash = false;
|
this._isPageRedirectingFromUrlHash = false;
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ class RoomDirectoryViewModel extends ViewModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
get roomDirectoryUrl() {
|
get roomDirectoryUrl() {
|
||||||
return this._matrixPublicArchiveURLCreator.roomDirectoryUrl();
|
return this._matrixViewerURLCreator.roomDirectoryUrl();
|
||||||
}
|
}
|
||||||
|
|
||||||
get pageSearchParameters() {
|
get pageSearchParameters() {
|
||||||
|
@ -301,7 +301,7 @@ class RoomDirectoryViewModel extends ViewModel {
|
||||||
|
|
||||||
get nextPageUrl() {
|
get nextPageUrl() {
|
||||||
if (this._nextPaginationToken) {
|
if (this._nextPaginationToken) {
|
||||||
return this._matrixPublicArchiveURLCreator.roomDirectoryUrl({
|
return this._matrixViewerURLCreator.roomDirectoryUrl({
|
||||||
homeserver: this.homeserverSelection,
|
homeserver: this.homeserverSelection,
|
||||||
searchTerm: this.searchTerm,
|
searchTerm: this.searchTerm,
|
||||||
paginationToken: this._nextPaginationToken,
|
paginationToken: this._nextPaginationToken,
|
||||||
|
@ -314,7 +314,7 @@ class RoomDirectoryViewModel extends ViewModel {
|
||||||
|
|
||||||
get prevPageUrl() {
|
get prevPageUrl() {
|
||||||
if (this._prevPaginationToken) {
|
if (this._prevPaginationToken) {
|
||||||
return this._matrixPublicArchiveURLCreator.roomDirectoryUrl({
|
return this._matrixViewerURLCreator.roomDirectoryUrl({
|
||||||
homeserver: this.homeserverSelection,
|
homeserver: this.homeserverSelection,
|
||||||
searchTerm: this.searchTerm,
|
searchTerm: this.searchTerm,
|
||||||
paginationToken: this._prevPaginationToken,
|
paginationToken: this._prevPaginationToken,
|
||||||
|
|
|
@ -11,23 +11,19 @@ const {
|
||||||
encodeEventIdKey,
|
encodeEventIdKey,
|
||||||
} = require('hydrogen-view-sdk');
|
} = require('hydrogen-view-sdk');
|
||||||
|
|
||||||
const assert = require('matrix-public-archive-shared/lib/assert');
|
const assert = require('matrix-viewer-shared/lib/assert');
|
||||||
|
|
||||||
const ModalViewModel = require('matrix-public-archive-shared/viewmodels/ModalViewModel');
|
const ModalViewModel = require('matrix-viewer-shared/viewmodels/ModalViewModel');
|
||||||
const MatrixPublicArchiveURLCreator = require('matrix-public-archive-shared/lib/url-creator');
|
const MatrixViewerURLCreator = require('matrix-viewer-shared/lib/url-creator');
|
||||||
const CalendarViewModel = require('matrix-public-archive-shared/viewmodels/CalendarViewModel');
|
const CalendarViewModel = require('matrix-viewer-shared/viewmodels/CalendarViewModel');
|
||||||
const TimeSelectorViewModel = require('matrix-public-archive-shared/viewmodels/TimeSelectorViewModel');
|
const TimeSelectorViewModel = require('matrix-viewer-shared/viewmodels/TimeSelectorViewModel');
|
||||||
const DeveloperOptionsContentViewModel = require('matrix-public-archive-shared/viewmodels/DeveloperOptionsContentViewModel');
|
const DeveloperOptionsContentViewModel = require('matrix-viewer-shared/viewmodels/DeveloperOptionsContentViewModel');
|
||||||
const RightPanelContentView = require('matrix-public-archive-shared/views/RightPanelContentView');
|
const RightPanelContentView = require('matrix-viewer-shared/views/RightPanelContentView');
|
||||||
const AvatarViewModel = require('matrix-public-archive-shared/viewmodels/AvatarViewModel');
|
const AvatarViewModel = require('matrix-viewer-shared/viewmodels/AvatarViewModel');
|
||||||
const {
|
const { customTileClassForEntry } = require('matrix-viewer-shared/lib/custom-tile-utilities');
|
||||||
customTileClassForEntry,
|
const stubPowerLevelsObservable = require('matrix-viewer-shared/lib/stub-powerlevels-observable');
|
||||||
} = require('matrix-public-archive-shared/lib/custom-tile-utilities');
|
const { TIME_PRECISION_VALUES } = require('matrix-viewer-shared/lib/reference-values');
|
||||||
const stubPowerLevelsObservable = require('matrix-public-archive-shared/lib/stub-powerlevels-observable');
|
const { areTimestampsFromSameUtcDay } = require('matrix-viewer-shared/lib/timestamp-utilities');
|
||||||
const { TIME_PRECISION_VALUES } = require('matrix-public-archive-shared/lib/reference-values');
|
|
||||||
const {
|
|
||||||
areTimestampsFromSameUtcDay,
|
|
||||||
} = require('matrix-public-archive-shared/lib/timestamp-utilities');
|
|
||||||
|
|
||||||
let txnCount = 0;
|
let txnCount = 0;
|
||||||
function getFakeEventId() {
|
function getFakeEventId() {
|
||||||
|
@ -61,13 +57,13 @@ function makeEventEntryFromEventJson(eventJson, memberEvent) {
|
||||||
return eventEntry;
|
return eventEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ArchiveRoomViewModel extends ViewModel {
|
class RoomViewModel extends ViewModel {
|
||||||
// eslint-disable-next-line max-statements, complexity
|
// eslint-disable-next-line max-statements, complexity
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
super(options);
|
super(options);
|
||||||
const {
|
const {
|
||||||
homeserverUrl,
|
homeserverUrl,
|
||||||
archiveMessageLimit,
|
messageLimit,
|
||||||
room,
|
room,
|
||||||
dayTimestampTo,
|
dayTimestampTo,
|
||||||
precisionFromUrl,
|
precisionFromUrl,
|
||||||
|
@ -79,7 +75,7 @@ class ArchiveRoomViewModel extends ViewModel {
|
||||||
basePath,
|
basePath,
|
||||||
} = options;
|
} = options;
|
||||||
assert(homeserverUrl);
|
assert(homeserverUrl);
|
||||||
assert(archiveMessageLimit);
|
assert(messageLimit);
|
||||||
assert(room);
|
assert(room);
|
||||||
assert(dayTimestampTo);
|
assert(dayTimestampTo);
|
||||||
assert(Object.values(TIME_PRECISION_VALUES).includes(precisionFromUrl));
|
assert(Object.values(TIME_PRECISION_VALUES).includes(precisionFromUrl));
|
||||||
|
@ -94,7 +90,7 @@ class ArchiveRoomViewModel extends ViewModel {
|
||||||
this._room = room;
|
this._room = room;
|
||||||
this._dayTimestampTo = dayTimestampTo;
|
this._dayTimestampTo = dayTimestampTo;
|
||||||
this._currentTopPositionEventEntry = null;
|
this._currentTopPositionEventEntry = null;
|
||||||
this._matrixPublicArchiveURLCreator = new MatrixPublicArchiveURLCreator(basePath);
|
this._matrixViewerURLCreator = new MatrixViewerURLCreator(basePath);
|
||||||
this._basePath = basePath;
|
this._basePath = basePath;
|
||||||
|
|
||||||
const navigation = this.navigation;
|
const navigation = this.navigation;
|
||||||
|
@ -139,12 +135,12 @@ class ArchiveRoomViewModel extends ViewModel {
|
||||||
const initialActiveDate = bottomMostEventDate || initialDate;
|
const initialActiveDate = bottomMostEventDate || initialDate;
|
||||||
|
|
||||||
this._calendarViewModel = new CalendarViewModel({
|
this._calendarViewModel = new CalendarViewModel({
|
||||||
// The day being shown in the archive
|
// The day being shown
|
||||||
activeDate: initialActiveDate,
|
activeDate: initialActiveDate,
|
||||||
// The month displayed in the calendar
|
// The month displayed in the calendar
|
||||||
calendarDate: initialActiveDate,
|
calendarDate: initialActiveDate,
|
||||||
room,
|
room,
|
||||||
matrixPublicArchiveURLCreator: this._matrixPublicArchiveURLCreator,
|
matrixViewerURLCreator: this._matrixViewerURLCreator,
|
||||||
});
|
});
|
||||||
|
|
||||||
const shouldShowTimeSelector =
|
const shouldShowTimeSelector =
|
||||||
|
@ -154,7 +150,7 @@ class ArchiveRoomViewModel extends ViewModel {
|
||||||
(precisionFromUrl !== TIME_PRECISION_VALUES.none && !events.length) ||
|
(precisionFromUrl !== TIME_PRECISION_VALUES.none && !events.length) ||
|
||||||
// Only show the time selector when we're showing events all from the same day and
|
// Only show the time selector when we're showing events all from the same day and
|
||||||
// there are more events than the limit
|
// there are more events than the limit
|
||||||
(events.length > archiveMessageLimit &&
|
(events.length > messageLimit &&
|
||||||
areTimestampsFromSameUtcDay(timelineRangeStartTimestamp, timelineRangeEndTimestamp));
|
areTimestampsFromSameUtcDay(timelineRangeStartTimestamp, timelineRangeEndTimestamp));
|
||||||
|
|
||||||
this._timeSelectorViewModel = new TimeSelectorViewModel({
|
this._timeSelectorViewModel = new TimeSelectorViewModel({
|
||||||
|
@ -162,7 +158,7 @@ class ArchiveRoomViewModel extends ViewModel {
|
||||||
// The time (within the given date) being displayed in the time scrubber.
|
// The time (within the given date) being displayed in the time scrubber.
|
||||||
activeDate: initialActiveDate,
|
activeDate: initialActiveDate,
|
||||||
// Prevent extra precision if it's not needed. We only need to show seconds if
|
// Prevent extra precision if it's not needed. We only need to show seconds if
|
||||||
// the page-loaded archive URL is worried about seconds.
|
// the page-loaded URL is worried about seconds.
|
||||||
preferredPrecision:
|
preferredPrecision:
|
||||||
// Default to minutes for the time selector otherwise use whatever more fine
|
// Default to minutes for the time selector otherwise use whatever more fine
|
||||||
// grained precision that the URL is using
|
// grained precision that the URL is using
|
||||||
|
@ -171,7 +167,7 @@ class ArchiveRoomViewModel extends ViewModel {
|
||||||
: precisionFromUrl,
|
: precisionFromUrl,
|
||||||
timelineRangeStartTimestamp,
|
timelineRangeStartTimestamp,
|
||||||
timelineRangeEndTimestamp,
|
timelineRangeEndTimestamp,
|
||||||
matrixPublicArchiveURLCreator: this._matrixPublicArchiveURLCreator,
|
matrixViewerURLCreator: this._matrixViewerURLCreator,
|
||||||
});
|
});
|
||||||
|
|
||||||
this._developerOptionsContentViewModel = new DeveloperOptionsContentViewModel(
|
this._developerOptionsContentViewModel = new DeveloperOptionsContentViewModel(
|
||||||
|
@ -334,11 +330,11 @@ class ArchiveRoomViewModel extends ViewModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
get roomDirectoryUrl() {
|
get roomDirectoryUrl() {
|
||||||
return this._matrixPublicArchiveURLCreator.roomDirectoryUrl();
|
return this._matrixViewerURLCreator.roomDirectoryUrl();
|
||||||
}
|
}
|
||||||
|
|
||||||
get roomPermalink() {
|
get roomPermalink() {
|
||||||
return this._matrixPublicArchiveURLCreator.permalinkForRoom(this._room.id);
|
return this._matrixViewerURLCreator.permalinkForRoom(this._room.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
get roomName() {
|
get roomName() {
|
||||||
|
@ -396,7 +392,7 @@ class ArchiveRoomViewModel extends ViewModel {
|
||||||
if (daySummaryKind !== 'no-events-at-all') {
|
if (daySummaryKind !== 'no-events-at-all') {
|
||||||
events.unshift({
|
events.unshift({
|
||||||
event_id: getFakeEventId(),
|
event_id: getFakeEventId(),
|
||||||
type: 'org.matrix.archive.jump_to_previous_activity_summary',
|
type: 'org.matrix.viewer.jump_to_previous_activity_summary',
|
||||||
room_id: this._room.id,
|
room_id: this._room.id,
|
||||||
// Even though this isn't used for sort, just using the time where the event
|
// Even though this isn't used for sort, just using the time where the event
|
||||||
// would logically be (before any of the other events in the timeline)
|
// would logically be (before any of the other events in the timeline)
|
||||||
|
@ -418,7 +414,7 @@ class ArchiveRoomViewModel extends ViewModel {
|
||||||
// on the day requested. Also allow the user to jump to the next activity in the room.
|
// on the day requested. Also allow the user to jump to the next activity in the room.
|
||||||
events.push({
|
events.push({
|
||||||
event_id: getFakeEventId(),
|
event_id: getFakeEventId(),
|
||||||
type: 'org.matrix.archive.jump_to_next_activity_summary',
|
type: 'org.matrix.viewer.jump_to_next_activity_summary',
|
||||||
room_id: this._room.id,
|
room_id: this._room.id,
|
||||||
// Even though this isn't used for sort, just using the time where the event
|
// Even though this isn't used for sort, just using the time where the event
|
||||||
// would logically be (at the end of the day)
|
// would logically be (at the end of the day)
|
||||||
|
@ -514,4 +510,4 @@ class ArchiveRoomViewModel extends ViewModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = ArchiveRoomViewModel;
|
module.exports = RoomViewModel;
|
|
@ -1,8 +1,8 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { ViewModel } = require('hydrogen-view-sdk');
|
const { ViewModel } = require('hydrogen-view-sdk');
|
||||||
const assert = require('matrix-public-archive-shared/lib/assert');
|
const assert = require('matrix-viewer-shared/lib/assert');
|
||||||
const { TIME_PRECISION_VALUES } = require('matrix-public-archive-shared/lib/reference-values');
|
const { TIME_PRECISION_VALUES } = require('matrix-viewer-shared/lib/reference-values');
|
||||||
|
|
||||||
class TimeSelectorViewModel extends ViewModel {
|
class TimeSelectorViewModel extends ViewModel {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
|
@ -13,11 +13,11 @@ class TimeSelectorViewModel extends ViewModel {
|
||||||
preferredPrecision = TIME_PRECISION_VALUES.minutes,
|
preferredPrecision = TIME_PRECISION_VALUES.minutes,
|
||||||
timelineRangeStartTimestamp,
|
timelineRangeStartTimestamp,
|
||||||
timelineRangeEndTimestamp,
|
timelineRangeEndTimestamp,
|
||||||
matrixPublicArchiveURLCreator,
|
matrixViewerURLCreator,
|
||||||
} = options;
|
} = options;
|
||||||
assert(room);
|
assert(room);
|
||||||
assert(activeDate);
|
assert(activeDate);
|
||||||
assert(matrixPublicArchiveURLCreator);
|
assert(matrixViewerURLCreator);
|
||||||
assert(
|
assert(
|
||||||
Object.values(TIME_PRECISION_VALUES).includes(preferredPrecision),
|
Object.values(TIME_PRECISION_VALUES).includes(preferredPrecision),
|
||||||
`TimeSelectorViewModel: options.preferredPrecision must be one of ${JSON.stringify(
|
`TimeSelectorViewModel: options.preferredPrecision must be one of ${JSON.stringify(
|
||||||
|
@ -33,7 +33,7 @@ class TimeSelectorViewModel extends ViewModel {
|
||||||
|
|
||||||
this._timelineRangeStartTimestamp = timelineRangeStartTimestamp;
|
this._timelineRangeStartTimestamp = timelineRangeStartTimestamp;
|
||||||
this._timelineRangeEndTimestamp = timelineRangeEndTimestamp;
|
this._timelineRangeEndTimestamp = timelineRangeEndTimestamp;
|
||||||
this._matrixPublicArchiveURLCreator = matrixPublicArchiveURLCreator;
|
this._matrixViewerURLCreator = matrixViewerURLCreator;
|
||||||
|
|
||||||
this._isDragging = false;
|
this._isDragging = false;
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ class TimeSelectorViewModel extends ViewModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
get goToActiveDateUrl() {
|
get goToActiveDateUrl() {
|
||||||
return this._matrixPublicArchiveURLCreator.archiveUrlForDate(
|
return this._matrixViewerURLCreator.roomUrlForDate(
|
||||||
this._room.canonicalAlias || this._room.id,
|
this._room.canonicalAlias || this._room.id,
|
||||||
this.activeDate,
|
this.activeDate,
|
||||||
{ preferredPrecision: this.preferredPrecision }
|
{ preferredPrecision: this.preferredPrecision }
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// Be mindful to do all date operations in UTC (the archive is all in UTC date/times)
|
// Be mindful to do all date operations in UTC (Matrix Viewer is all in UTC date/times)
|
||||||
|
|
||||||
const { TemplateView } = require('hydrogen-view-sdk');
|
const { TemplateView } = require('hydrogen-view-sdk');
|
||||||
const {
|
const { areTimestampsFromSameUtcDay } = require('matrix-viewer-shared/lib/timestamp-utilities');
|
||||||
areTimestampsFromSameUtcDay,
|
|
||||||
} = require('matrix-public-archive-shared/lib/timestamp-utilities');
|
|
||||||
|
|
||||||
// Get the number of days in the given month where the `inputDate` lies.
|
// Get the number of days in the given month where the `inputDate` lies.
|
||||||
//
|
//
|
||||||
|
@ -156,7 +154,7 @@ class CalendarView extends TemplateView {
|
||||||
dayNumberDate.setUTCDate(i + 1);
|
dayNumberDate.setUTCDate(i + 1);
|
||||||
const isDayInFuture = dayNumberDate.getTime() - todayTs > 0;
|
const isDayInFuture = dayNumberDate.getTime() - todayTs > 0;
|
||||||
|
|
||||||
// The current day displayed in the archive
|
// The current day displayed
|
||||||
const isActive = areTimestampsFromSameUtcDay(
|
const isActive = areTimestampsFromSameUtcDay(
|
||||||
dayNumberDate.getTime(),
|
dayNumberDate.getTime(),
|
||||||
vm.activeDate.getTime()
|
vm.activeDate.getTime()
|
||||||
|
@ -184,7 +182,7 @@ class CalendarView extends TemplateView {
|
||||||
CalendarView_dayLink_disabled: isDayInFuture,
|
CalendarView_dayLink_disabled: isDayInFuture,
|
||||||
},
|
},
|
||||||
// Disable navigation to future days
|
// Disable navigation to future days
|
||||||
href: isDayInFuture ? null : vm.archiveUrlForDate(dayNumberDate),
|
href: isDayInFuture ? null : vm.roomUrlForDate(dayNumberDate),
|
||||||
},
|
},
|
||||||
[String(dayNumberDate.getUTCDate())]
|
[String(dayNumberDate.getUTCDate())]
|
||||||
),
|
),
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
const { TemplateView } = require('hydrogen-view-sdk');
|
const { TemplateView } = require('hydrogen-view-sdk');
|
||||||
|
|
||||||
const assert = require('matrix-public-archive-shared/lib/assert');
|
const assert = require('matrix-viewer-shared/lib/assert');
|
||||||
const CalendarView = require('matrix-public-archive-shared/views/CalendarView');
|
const CalendarView = require('matrix-viewer-shared/views/CalendarView');
|
||||||
const TimeSelectorView = require('matrix-public-archive-shared/views/TimeSelectorView');
|
const TimeSelectorView = require('matrix-viewer-shared/views/TimeSelectorView');
|
||||||
|
|
||||||
class RightPanelContentView extends TemplateView {
|
class RightPanelContentView extends TemplateView {
|
||||||
render(t, vm) {
|
render(t, vm) {
|
||||||
|
@ -50,7 +50,7 @@ class RightPanelContentView extends TemplateView {
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
t.p([
|
t.p([
|
||||||
`This room is accessible in the archive because it was set to ` +
|
`This room is accessible because it was set to ` +
|
||||||
`${historyVisibilityDisplayValue} by ${historyVisibilitySender} on ${historyVisibilitySetDatePiece}.`,
|
`${historyVisibilityDisplayValue} by ${historyVisibilitySender} on ${historyVisibilitySetDatePiece}.`,
|
||||||
]),
|
]),
|
||||||
t.p([
|
t.p([
|
||||||
|
@ -59,7 +59,7 @@ class RightPanelContentView extends TemplateView {
|
||||||
t.a(
|
t.a(
|
||||||
{
|
{
|
||||||
className: 'external-link RightPanelContentView_footerLink',
|
className: 'external-link RightPanelContentView_footerLink',
|
||||||
href: 'https://github.com/matrix-org/matrix-public-archive/blob/main/docs/faq.md#how-do-i-opt-out-and-keep-my-room-from-being-indexed-by-search-engines',
|
href: 'https://github.com/matrix-org/matrix-viewer/blob/main/docs/faq.md#how-do-i-opt-out-and-keep-my-room-from-being-indexed-by-search-engines',
|
||||||
target: '_blank',
|
target: '_blank',
|
||||||
},
|
},
|
||||||
'more info'
|
'more info'
|
||||||
|
|
|
@ -57,7 +57,7 @@ class RoomCardView extends TemplateView {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return vm.archiveRoomUrl;
|
return vm.roomUrl;
|
||||||
},
|
},
|
||||||
// Since this is the same button as the "View" link, just tab to
|
// Since this is the same button as the "View" link, just tab to
|
||||||
// that instead
|
// that instead
|
||||||
|
@ -107,7 +107,7 @@ class RoomCardView extends TemplateView {
|
||||||
t.a(
|
t.a(
|
||||||
{
|
{
|
||||||
className: 'RoomCardView_alias',
|
className: 'RoomCardView_alias',
|
||||||
href: vm.archiveRoomUrl,
|
href: vm.roomUrl,
|
||||||
// Since this is the same button as the "View" link, just tab to
|
// Since this is the same button as the "View" link, just tab to
|
||||||
// that instead
|
// that instead
|
||||||
tabindex: -1,
|
tabindex: -1,
|
||||||
|
@ -145,7 +145,7 @@ class RoomCardView extends TemplateView {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return vm.archiveRoomUrl;
|
return vm.roomUrl;
|
||||||
},
|
},
|
||||||
title: (vm) => {
|
title: (vm) => {
|
||||||
if (vm.blockedBySafeSearch) {
|
if (vm.blockedBySafeSearch) {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
const { TemplateView, ListView, text } = require('hydrogen-view-sdk');
|
const { TemplateView, ListView, text } = require('hydrogen-view-sdk');
|
||||||
|
|
||||||
const ModalView = require('matrix-public-archive-shared/views/ModalView');
|
const ModalView = require('matrix-viewer-shared/views/ModalView');
|
||||||
const HomeserverSelectionModalContentView = require('./HomeserverSelectionModalContentView');
|
const HomeserverSelectionModalContentView = require('./HomeserverSelectionModalContentView');
|
||||||
const MatrixLogoView = require('./MatrixLogoView');
|
const MatrixLogoView = require('./MatrixLogoView');
|
||||||
const RoomCardView = require('./RoomCardView');
|
const RoomCardView = require('./RoomCardView');
|
||||||
|
@ -117,7 +117,7 @@ class RoomDirectoryView extends TemplateView {
|
||||||
t.a(
|
t.a(
|
||||||
{
|
{
|
||||||
className: 'RoomDirectoryView_matrixLogo',
|
className: 'RoomDirectoryView_matrixLogo',
|
||||||
title: 'Matrix Public Archive',
|
title: 'Matrix Viewer',
|
||||||
href: vm.roomDirectoryUrl,
|
href: vm.roomDirectoryUrl,
|
||||||
},
|
},
|
||||||
[t.view(new MatrixLogoView(vm))]
|
[t.view(new MatrixLogoView(vm))]
|
||||||
|
@ -217,9 +217,9 @@ class RoomDirectoryView extends TemplateView {
|
||||||
[
|
[
|
||||||
t.h3('❗ Unable to fetch rooms from room directory'),
|
t.h3('❗ Unable to fetch rooms from room directory'),
|
||||||
t.p({}, [
|
t.p({}, [
|
||||||
`This may be a temporary problem with the homeserver where the room directory lives (${vm.pageSearchParameters.homeserver}) or the homeserver that the archive is pulling from (${vm.homeserverName}). You can try adjusting your search or select a different homeserver to look at. If this problem persists, please check the homeserver status and with a homeserver admin first, then open a `,
|
`This may be a temporary problem with the homeserver where the room directory lives (${vm.pageSearchParameters.homeserver}) or the remote homeserver that we are pulling from (${vm.homeserverName}). You can try adjusting your search or select a different homeserver to look at. If this problem persists, please check the homeserver status and with a homeserver admin first, then open a `,
|
||||||
t.a(
|
t.a(
|
||||||
{ href: 'https://github.com/matrix-org/matrix-public-archive/issues/new' },
|
{ href: 'https://github.com/matrix-org/matrix-viewer/issues/new' },
|
||||||
'bug report'
|
'bug report'
|
||||||
),
|
),
|
||||||
` with this whole section copy-pasted into the issue.`,
|
` with this whole section copy-pasted into the issue.`,
|
||||||
|
@ -248,7 +248,7 @@ class RoomDirectoryView extends TemplateView {
|
||||||
t.p({}, [
|
t.p({}, [
|
||||||
`We're showing as much detail as we know so you're not frustrated by a generic message with no feedback on how to move forward. This also makes it easier for you to write a `,
|
`We're showing as much detail as we know so you're not frustrated by a generic message with no feedback on how to move forward. This also makes it easier for you to write a `,
|
||||||
t.a(
|
t.a(
|
||||||
{ href: 'https://github.com/matrix-org/matrix-public-archive/issues/new' },
|
{ href: 'https://github.com/matrix-org/matrix-viewer/issues/new' },
|
||||||
'bug report'
|
'bug report'
|
||||||
),
|
),
|
||||||
` with all the details necessary for us to triage it.`,
|
` with all the details necessary for us to triage it.`,
|
||||||
|
@ -256,10 +256,7 @@ class RoomDirectoryView extends TemplateView {
|
||||||
t.p({}, t.strong(`Isn't this a security risk?`)),
|
t.p({}, t.strong(`Isn't this a security risk?`)),
|
||||||
t.p({}, [
|
t.p({}, [
|
||||||
`Not really. Usually, people are worried about returning details because it makes it easier for people to probe the system by getting better feedback about what's going wrong to craft exploits. But the `,
|
`Not really. Usually, people are worried about returning details because it makes it easier for people to probe the system by getting better feedback about what's going wrong to craft exploits. But the `,
|
||||||
t.a(
|
t.a({ href: 'https://github.com/matrix-org/matrix-viewer' }, 'Matrix Viewer'),
|
||||||
{ href: 'https://github.com/matrix-org/matrix-public-archive' },
|
|
||||||
'Matrix Public Archive'
|
|
||||||
),
|
|
||||||
` is already open source so the details of the app are already public and you can run your own instance against the same homeservers that we are to find problems.`,
|
` is already open source so the details of the app are already public and you can run your own instance against the same homeservers that we are to find problems.`,
|
||||||
]),
|
]),
|
||||||
t.p({}, [
|
t.p({}, [
|
||||||
|
@ -273,7 +270,7 @@ class RoomDirectoryView extends TemplateView {
|
||||||
t.p({}, [
|
t.p({}, [
|
||||||
`If you have ideas on how we can better present these errors, please `,
|
`If you have ideas on how we can better present these errors, please `,
|
||||||
t.a(
|
t.a(
|
||||||
{ href: 'https://github.com/matrix-org/matrix-public-archive/issues' },
|
{ href: 'https://github.com/matrix-org/matrix-viewer/issues' },
|
||||||
'create an issue'
|
'create an issue'
|
||||||
),
|
),
|
||||||
`.`,
|
`.`,
|
||||||
|
|
|
@ -8,12 +8,10 @@ const {
|
||||||
LightboxView,
|
LightboxView,
|
||||||
} = require('hydrogen-view-sdk');
|
} = require('hydrogen-view-sdk');
|
||||||
|
|
||||||
const {
|
const { customViewClassForTile } = require('matrix-viewer-shared/lib/custom-tile-utilities');
|
||||||
customViewClassForTile,
|
|
||||||
} = require('matrix-public-archive-shared/lib/custom-tile-utilities');
|
|
||||||
|
|
||||||
const DeveloperOptionsContentView = require('matrix-public-archive-shared/views/DeveloperOptionsContentView');
|
const DeveloperOptionsContentView = require('matrix-viewer-shared/views/DeveloperOptionsContentView');
|
||||||
const ModalView = require('matrix-public-archive-shared/views/ModalView');
|
const ModalView = require('matrix-viewer-shared/views/ModalView');
|
||||||
|
|
||||||
class RoomHeaderView extends TemplateView {
|
class RoomHeaderView extends TemplateView {
|
||||||
render(t, vm) {
|
render(t, vm) {
|
||||||
|
@ -90,13 +88,13 @@ class DisabledComposerView extends TemplateView {
|
||||||
(vm) => vm.currentTopPositionEventEntry,
|
(vm) => vm.currentTopPositionEventEntry,
|
||||||
(_currentTopPositionEventEntry, t, vm) => {
|
(_currentTopPositionEventEntry, t, vm) => {
|
||||||
const activeDate = new Date(
|
const activeDate = new Date(
|
||||||
// If the date from our `archiveRoomViewModel` is available, use that
|
// If the date from our `roomViewModel` is available, use that
|
||||||
vm?.currentTopPositionEventEntry?.timestamp ||
|
vm?.currentTopPositionEventEntry?.timestamp ||
|
||||||
// Otherwise, use our initial `dayTimestampTo`
|
// Otherwise, use our initial `dayTimestampTo`
|
||||||
vm.dayTimestampTo
|
vm.dayTimestampTo
|
||||||
);
|
);
|
||||||
const dateString = activeDate.toISOString().split('T')[0];
|
const dateString = activeDate.toISOString().split('T')[0];
|
||||||
return t.span(`You're viewing an archive of events from ${dateString}. Use a `);
|
return t.span(`You're viewing a snapshot of events from ${dateString}. Use a `);
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
t.a(
|
t.a(
|
||||||
|
@ -113,7 +111,7 @@ class DisabledComposerView extends TemplateView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ArchiveRoomView extends TemplateView {
|
class RoomView extends TemplateView {
|
||||||
constructor(vm) {
|
constructor(vm) {
|
||||||
super(vm);
|
super(vm);
|
||||||
|
|
||||||
|
@ -131,7 +129,7 @@ class ArchiveRoomView extends TemplateView {
|
||||||
const rootElement = t.div(
|
const rootElement = t.div(
|
||||||
{
|
{
|
||||||
className: {
|
className: {
|
||||||
ArchiveRoomView: true,
|
RoomView: true,
|
||||||
'right-shown': (vm) => vm.shouldShowRightPanel,
|
'right-shown': (vm) => vm.shouldShowRightPanel,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -156,9 +154,9 @@ class ArchiveRoomView extends TemplateView {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
t.main({ className: 'ArchiveRoomView_mainArea' }, [
|
t.main({ className: 'RoomView_mainArea' }, [
|
||||||
t.view(new RoomHeaderView(vm)),
|
t.view(new RoomHeaderView(vm)),
|
||||||
t.main({ className: 'ArchiveRoomView_mainBody' }, [
|
t.main({ className: 'RoomView_mainBody' }, [
|
||||||
t.view(new TimelineView(vm.timelineViewModel, customViewClassForTile)),
|
t.view(new TimelineView(vm.timelineViewModel, customViewClassForTile)),
|
||||||
t.view(new DisabledComposerView(vm)),
|
t.view(new DisabledComposerView(vm)),
|
||||||
]),
|
]),
|
||||||
|
@ -218,4 +216,4 @@ class ArchiveRoomView extends TemplateView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = ArchiveRoomView;
|
module.exports = RoomView;
|
|
@ -1,13 +1,10 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const assert = require('matrix-public-archive-shared/lib/assert');
|
const assert = require('matrix-viewer-shared/lib/assert');
|
||||||
const { TemplateView } = require('hydrogen-view-sdk');
|
const { TemplateView } = require('hydrogen-view-sdk');
|
||||||
const {
|
const { MS_LOOKUP, TIME_PRECISION_VALUES } = require('matrix-viewer-shared/lib/reference-values');
|
||||||
MS_LOOKUP,
|
|
||||||
TIME_PRECISION_VALUES,
|
|
||||||
} = require('matrix-public-archive-shared/lib/reference-values');
|
|
||||||
const { ONE_DAY_IN_MS, ONE_HOUR_IN_MS, ONE_MINUTE_IN_MS, ONE_SECOND_IN_MS } = MS_LOOKUP;
|
const { ONE_DAY_IN_MS, ONE_HOUR_IN_MS, ONE_MINUTE_IN_MS, ONE_SECOND_IN_MS } = MS_LOOKUP;
|
||||||
const { getUtcStartOfDayTs } = require('matrix-public-archive-shared/lib/timestamp-utilities');
|
const { getUtcStartOfDayTs } = require('matrix-viewer-shared/lib/timestamp-utilities');
|
||||||
|
|
||||||
function clamp(input, min, max) {
|
function clamp(input, min, max) {
|
||||||
assert(input !== undefined);
|
assert(input !== undefined);
|
||||||
|
|
|
@ -2,14 +2,14 @@ version: '3'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
hs1:
|
hs1:
|
||||||
image: matrix-public-archive-test-homeserver:latest
|
image: matrix-viewer-test-homeserver:latest
|
||||||
ports:
|
ports:
|
||||||
- '11008:8008'
|
- '11008:8008'
|
||||||
environment:
|
environment:
|
||||||
- SERVER_NAME=hs1
|
- SERVER_NAME=hs1
|
||||||
|
|
||||||
hs2:
|
hs2:
|
||||||
image: matrix-public-archive-test-homeserver:latest
|
image: matrix-viewer-test-homeserver:latest
|
||||||
ports:
|
ports:
|
||||||
- '12008:8008'
|
- '12008:8008'
|
||||||
environment:
|
environment:
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
id: 6527ecdd6b8fe61c645d9d412222d75b
|
id: matrix_viewer_foobarbaz
|
||||||
hs_token: hs_token_1f5d7675517072f0c0b5b684ca23f9ffad5a0cfc32e1ca824c0600ee74e105d7
|
hs_token: hs_token_as_token_matrix_viewer_foobarbaz
|
||||||
# We use this as a consistent acccess token to use in our tests
|
# We use this as a consistent acccess token to use in our tests
|
||||||
as_token: as_token_8664700429a911bbbecf7d91b9e1a74716d669f40cf32259630e38439726e29d
|
as_token: as_token_matrix_viewer_foobarbaz
|
||||||
# This doesn't relate to anything else
|
# This doesn't relate to anything else
|
||||||
url: 'http://localhost:0000'
|
url: 'http://localhost:0000'
|
||||||
sender_localpart: archiver
|
sender_localpart: view
|
||||||
namespaces:
|
namespaces:
|
||||||
users:
|
users:
|
||||||
- exclusive: false
|
- exclusive: false
|
||||||
|
|
|
@ -14,7 +14,7 @@ allow_public_rooms_over_federation: true
|
||||||
tls_certificate_path: /conf/server.tls.crt
|
tls_certificate_path: /conf/server.tls.crt
|
||||||
tls_private_key_path: /conf/server.tls.key
|
tls_private_key_path: /conf/server.tls.key
|
||||||
bcrypt_rounds: 4
|
bcrypt_rounds: 4
|
||||||
registration_shared_secret: matrix_public_archive
|
registration_shared_secret: matrix_viewer
|
||||||
|
|
||||||
listeners:
|
listeners:
|
||||||
- port: 8448
|
- port: 8448
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -14,8 +14,8 @@ describe('getServerNameFromMatrixRoomIdOrAlias', () => {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'can parse sub-domain',
|
name: 'can parse sub-domain',
|
||||||
input: '!foo:archive.matrix.org',
|
input: '!foo:view.matrix.org',
|
||||||
expected: 'archive.matrix.org',
|
expected: 'view.matrix.org',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'can parse domain with port',
|
name: 'can parse domain with port',
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
const checkTextForNsfw = require('matrix-public-archive-shared/lib/check-text-for-nsfw');
|
const checkTextForNsfw = require('matrix-viewer-shared/lib/check-text-for-nsfw');
|
||||||
|
|
||||||
describe('checkTextForNsfw', () => {
|
describe('checkTextForNsfw', () => {
|
||||||
Object.entries({
|
Object.entries({
|
||||||
|
|
|
@ -15,7 +15,7 @@ const {
|
||||||
areTimestampsFromSameUtcHour,
|
areTimestampsFromSameUtcHour,
|
||||||
areTimestampsFromSameUtcMinute,
|
areTimestampsFromSameUtcMinute,
|
||||||
areTimestampsFromSameUtcSecond,
|
areTimestampsFromSameUtcSecond,
|
||||||
} = require('matrix-public-archive-shared/lib/timestamp-utilities');
|
} = require('matrix-viewer-shared/lib/timestamp-utilities');
|
||||||
|
|
||||||
describe('timestamp-utilities', () => {
|
describe('timestamp-utilities', () => {
|
||||||
describe('roundUpTimestampToUtcX', () => {
|
describe('roundUpTimestampToUtcX', () => {
|
||||||
|
|
|
@ -4,7 +4,7 @@ const assert = require('assert');
|
||||||
const urlJoin = require('url-join');
|
const urlJoin = require('url-join');
|
||||||
const { fetchEndpointAsJson, fetchEndpoint } = require('../../server/lib/fetch-endpoint');
|
const { fetchEndpointAsJson, fetchEndpoint } = require('../../server/lib/fetch-endpoint');
|
||||||
const getServerNameFromMatrixRoomIdOrAlias = require('../../server/lib/matrix-utils/get-server-name-from-matrix-room-id-or-alias');
|
const getServerNameFromMatrixRoomIdOrAlias = require('../../server/lib/matrix-utils/get-server-name-from-matrix-room-id-or-alias');
|
||||||
const { MS_LOOKUP } = require('matrix-public-archive-shared/lib/reference-values');
|
const { MS_LOOKUP } = require('matrix-viewer-shared/lib/reference-values');
|
||||||
const { ONE_SECOND_IN_MS } = MS_LOOKUP;
|
const { ONE_SECOND_IN_MS } = MS_LOOKUP;
|
||||||
|
|
||||||
const config = require('../../server/lib/config');
|
const config = require('../../server/lib/config');
|
||||||
|
@ -52,7 +52,7 @@ async function getTestClientForAs() {
|
||||||
return {
|
return {
|
||||||
homeserverUrl: testMatrixServerUrl1,
|
homeserverUrl: testMatrixServerUrl1,
|
||||||
accessToken: matrixAccessToken,
|
accessToken: matrixAccessToken,
|
||||||
userId: '@archiver:hs1',
|
userId: '@view:hs1',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ async function upgradeTestRoom({
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Pass `timestamp` massaging option to `createTestRoom()` when it supports it,
|
// TODO: Pass `timestamp` massaging option to `createTestRoom()` when it supports it,
|
||||||
// see https://github.com/matrix-org/matrix-public-archive/issues/169
|
// see https://github.com/matrix-org/matrix-viewer/issues/169
|
||||||
const newRoomid = await createTestRoom(client, createOptions);
|
const newRoomid = await createTestRoom(client, createOptions);
|
||||||
|
|
||||||
// Now send the tombstone event pointing from the old room to the new room
|
// Now send the tombstone event pointing from the old room to the new room
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
|
|
||||||
const {
|
const {
|
||||||
VALID_ENTITY_DESCRIPTOR_TO_SIGIL_MAP,
|
VALID_ENTITY_DESCRIPTOR_TO_SIGIL_MAP,
|
||||||
} = require('matrix-public-archive-shared/lib/reference-values');
|
} = require('matrix-viewer-shared/lib/reference-values');
|
||||||
|
|
||||||
// http://archive.matrix.org/r/some-room:matrix.org/date/2022/11/16T23:59:59?at=$xxx
|
// http://view.matrix.org/r/some-room:matrix.org/date/2022/11/16T23:59:59?at=$xxx
|
||||||
function parseArchiveUrlForRoom(archiveUrlForRoom) {
|
function parseMatrixViewerUrlForRoom(roomUrl) {
|
||||||
const urlObj = new URL(archiveUrlForRoom);
|
const urlObj = new URL(roomUrl);
|
||||||
const urlPathname = urlObj.pathname;
|
const urlPathname = urlObj.pathname;
|
||||||
|
|
||||||
const [_match, roomIdOrAliasDescriptor, roomIdOrAliasUrlPart, urlDateTime] = urlPathname.match(
|
const [_match, roomIdOrAliasDescriptor, roomIdOrAliasUrlPart, urlDateTime] = urlPathname.match(
|
||||||
|
@ -26,4 +26,4 @@ function parseArchiveUrlForRoom(archiveUrlForRoom) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = parseArchiveUrlForRoom;
|
module.exports = parseMatrixViewerUrlForRoom;
|
Loading…
Reference in New Issue