Add via parameter on join room requests as per MSC4156 (#3441)

This implements
[MSC4156](https://github.com/matrix-org/matrix-spec-proposals/pull/4156)
which will ship with Matrix 1.12 and is the continuation of
https://github.com/matrix-org/dendrite/pull/3438.

### Pull Request Checklist

<!-- Please read
https://matrix-org.github.io/dendrite/development/contributing before
submitting your pull request -->

* [ ] I have added Go unit tests or [Complement integration
tests](https://github.com/matrix-org/complement) for this PR _or_ I have
justified why this PR doesn't need tests
* [x] Pull request includes a [sign off below using a legally
identifiable
name](https://matrix-org.github.io/dendrite/development/contributing#sign-off)
_or_ I have already signed off privately

Signed-off-by: Johannes Marbach <n0-0ne+github@mailbox.org>

Signed-off-by: Johannes Marbach <n0-0ne+github@mailbox.org>
Co-authored-by: Till <2353100+S7evinK@users.noreply.github.com>
This commit is contained in:
Johannes Marbach 2024-12-09 20:31:20 +01:00 committed by GitHub
parent 7cc7ebb46f
commit 7acf32f24d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -36,9 +36,16 @@ func JoinRoomByIDOrAlias(
Content: map[string]interface{}{},
}
// Check to see if any ?server_name= query parameters were
// given in the request.
if serverNames, ok := req.URL.Query()["server_name"]; ok {
// Check to see if any ?via= or ?server_name= query parameters
// were given in the request.
if serverNames, ok := req.URL.Query()["via"]; ok {
for _, serverName := range serverNames {
joinReq.ServerNames = append(
joinReq.ServerNames,
spec.ServerName(serverName),
)
}
} else if serverNames, ok := req.URL.Query()["server_name"]; ok {
for _, serverName := range serverNames {
joinReq.ServerNames = append(
joinReq.ServerNames,