-
Notifications
You must be signed in to change notification settings - Fork 11
Add test for joining a new federated room #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
MadLittleMods
merged 15 commits into
main
from
madlittlemods/test-for-join-new-federated-room
Aug 29, 2022
Merged
Changes from 9 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
2fc9e16
Add test for joining a new federated room
MadLittleMods 8643332
Past join problems
MadLittleMods 298d941
Add macOS reference
MadLittleMods 1754dfe
Merge branch 'main' into madlittlemods/test-for-join-new-federated-room
MadLittleMods 014f4a9
Merge branch 'main' into madlittlemods/test-for-join-new-federated-room
MadLittleMods a516663
name change
MadLittleMods a7e7c69
Merge branch 'main' into madlittlemods/test-for-join-new-federated-room
MadLittleMods e8b29ef
Merge branch 'main' into madlittlemods/test-for-join-new-federated-room
MadLittleMods e1d056f
Remove unnecessary Docker compose number difference between platforms
MadLittleMods 06e9395
Remove `URLSearchParams` import because it works without and more com…
MadLittleMods 9549acf
Only add the ? if there are query parameters
MadLittleMods 00c1024
Better test assertion that tells you what's missing
MadLittleMods 5b2b03a
Fix test failing because the homeserver backfilled the first instead …
MadLittleMods d4270a8
Remove `it.only`
MadLittleMods 12b62ff
Note that this isn't necessary once https://github.com/matrix-org/syn…
MadLittleMods File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,34 @@ | ||
'use strict'; | ||
|
||
const assert = require('assert'); | ||
const { URLSearchParams } = require('url'); | ||
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()}` | ||
); | ||
console.log('joinEndpoint', joinEndpoint); | ||
await fetchEndpointAsJson(joinEndpoint, { | ||
method: 'POST', | ||
accessToken, | ||
}); | ||
} | ||
|
||
module.exports = ensureRoomJoined; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.