-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for joining a new federated room (#31)
Add test for joining a new federated room and making sure the messages are available (homeserver should backfill). Synapse changes: matrix-org/synapse#13205, matrix-org/synapse#13320
- Loading branch information
1 parent
b5b79b9
commit e9d13db
Showing
6 changed files
with
179 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
'use strict'; | ||
|
||
const assert = require('assert'); | ||
const urlJoin = require('url-join'); | ||
|
||
const { fetchEndpointAsJson } = require('./lib/fetch-endpoint'); | ||
|
||
const config = require('./lib/config'); | ||
const matrixServerUrl = config.get('matrixServerUrl'); | ||
assert(matrixServerUrl); | ||
|
||
async function ensureRoomJoined(accessToken, roomId, viaServers = []) { | ||
let qs = new URLSearchParams(); | ||
[].concat(viaServers).forEach((viaServer) => { | ||
qs.append('server_name', viaServer); | ||
}); | ||
|
||
// TODO: Only join world_readable rooms. Perhaps we want to serve public rooms | ||
// where we have been invited. GET | ||
// /_matrix/client/v3/directory/list/room/{roomId} (Gets the visibility of a | ||
// given room on the server’s public room directory.) | ||
const joinEndpoint = urlJoin( | ||
matrixServerUrl, | ||
`_matrix/client/r0/join/${roomId}?${qs.toString()}` | ||
); | ||
await fetchEndpointAsJson(joinEndpoint, { | ||
method: 'POST', | ||
accessToken, | ||
}); | ||
} | ||
|
||
module.exports = ensureRoomJoined; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters