Skip to content

Commit 77be78c

Browse files
authored
fix: pass correct supported versions list to make_join (#236)
1 parent 61636af commit 77be78c

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

packages/federation-sdk/src/services/federation-request.service.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,19 @@ export class FederationRequestService {
121121
targetServer: string,
122122
endpoint: string,
123123
body?: Record<string, unknown>,
124-
queryParams?: Record<string, string>,
124+
queryParams?: Record<string, string | string[]>,
125125
) {
126126
let queryString = '';
127127

128128
if (queryParams) {
129129
const params = new URLSearchParams();
130130
for (const [key, value] of Object.entries(queryParams)) {
131+
if (Array.isArray(value)) {
132+
for (const v of value) {
133+
params.append(key, v);
134+
}
135+
continue;
136+
}
131137
params.append(key, value);
132138
}
133139
queryString = params.toString();
@@ -147,7 +153,7 @@ export class FederationRequestService {
147153
async get<T>(
148154
targetServer: string,
149155
endpoint: string,
150-
queryParams?: Record<string, string>,
156+
queryParams?: Record<string, string | string[]>,
151157
): Promise<T> {
152158
return this.request<T>(
153159
'GET',

packages/federation-sdk/src/services/federation.service.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
Pdu,
77
PduForType,
88
PersistentEventBase,
9+
PersistentEventFactory,
910
} from '@rocket.chat/federation-room';
1011
import { singleton } from 'tsyringe';
1112
import {
@@ -43,16 +44,12 @@ export class FederationService {
4344
): Promise<MakeJoinResponse> {
4445
try {
4546
const uri = FederationEndpoints.makeJoin(roomId, userId);
46-
const queryParams: Record<string, string> = {};
47+
const queryParams: Record<string, string | string[]> = {};
4748

4849
if (version) {
4950
queryParams.ver = version;
5051
} else {
51-
// 3-11 is what we support now
52-
// FIXME: this is wrong, for now just passing 10 to check if supported, we need ver=1&ver=2 and so on.
53-
for (let ver = 3; ver <= 11; ver++) {
54-
queryParams[`ver${ver === 1 ? '' : ver}`] = ver.toString();
55-
}
52+
queryParams.ver = PersistentEventFactory.supportedRoomVersions;
5653
}
5754

5855
return await this.requestService.get<MakeJoinResponse>(

0 commit comments

Comments
 (0)