Use full archive URL for room in the reason

See https://github.com/matrix-org/matrix-public-archive/pull/262#discussion_r1219137857
This commit is contained in:
Eric Eastwood 2023-06-06 11:48:35 -05:00
parent 10e1f42266
commit 3d4096a582
1 changed files with 12 additions and 2 deletions

View File

@ -3,14 +3,19 @@
const assert = require('assert'); const assert = require('assert');
const urlJoin = require('url-join'); const urlJoin = require('url-join');
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 config = require('../config'); const config = require('../config');
const StatusError = require('../errors/status-error'); const basePath = config.get('basePath');
assert(basePath);
const matrixServerUrl = config.get('matrixServerUrl'); const matrixServerUrl = config.get('matrixServerUrl');
assert(matrixServerUrl); assert(matrixServerUrl);
const matrixPublicArchiveURLCreator = new MatrixPublicArchiveURLCreator(basePath);
async function ensureRoomJoined( async function ensureRoomJoined(
accessToken, accessToken,
roomIdOrAlias, roomIdOrAlias,
@ -47,7 +52,12 @@ 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 at archive.matrix.org. ` + `it will be accessible at ${matrixPublicArchiveURLCreator.archiveUrlForRoom(
roomIdOrAlias
// We don't need to include the `viaServers` option here because the archive
// will already be joined to the room from this request itself and we don't
// need to make the URL any longer/noisier than it needs to be.
)}. ` +
`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-public-archive/blob/main/docs/faq.md#why-did-the-archive-bot-join-my-room`,
}, },