Skip to content

Commit df11a9e

Browse files
authored
Fix sending undefined query args to Synapse (#2070)
1 parent e470398 commit df11a9e

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

src/client.ts

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4285,7 +4285,7 @@ export class MatrixClient extends EventEmitter {
42854285
const resp = this.http.authedRequest(
42864286
callback, Method.Get, "/preview_url", {
42874287
url,
4288-
ts: String(ts),
4288+
ts: ts.toString(),
42894289
}, undefined, {
42904290
prefix: PREFIX_MEDIA_R0,
42914291
},
@@ -5016,18 +5016,16 @@ export class MatrixClient extends EventEmitter {
50165016
public createMessagesRequest(
50175017
roomId: string,
50185018
fromToken: string,
5019-
limit: number,
5019+
limit = 30,
50205020
dir: Direction,
50215021
timelineFilter?: Filter,
50225022
): Promise<IMessagesResponse> {
50235023
const path = utils.encodeUri("/rooms/$roomId/messages", { $roomId: roomId });
5024-
if (limit === undefined) {
5025-
limit = 30;
5026-
}
5024+
50275025
const params: Record<string, string> = {
50285026
from: fromToken,
5029-
limit: String(limit),
5030-
dir: dir,
5027+
limit: limit.toString(),
5028+
dir,
50315029
};
50325030

50335031
let filter = null;
@@ -6956,13 +6954,12 @@ export class MatrixClient extends EventEmitter {
69566954
callback = limit as any as Callback; // legacy
69576955
limit = undefined;
69586956
}
6957+
69596958
const path = utils.encodeUri("/rooms/$roomId/initialSync",
69606959
{ $roomId: roomId },
69616960
);
6962-
if (!limit) {
6963-
limit = 30;
6964-
}
6965-
return this.http.authedRequest(callback, Method.Get, path, { limit: String(limit) });
6961+
6962+
return this.http.authedRequest(callback, Method.Get, path, { limit: limit?.toString() ?? "30" });
69666963
}
69676964

69686965
/**
@@ -7873,7 +7870,7 @@ export class MatrixClient extends EventEmitter {
78737870
const params = {
78747871
client_secret: clientSecret,
78757872
email: email,
7876-
send_attempt: String(sendAttempt),
7873+
send_attempt: sendAttempt?.toString(),
78777874
next_link: nextLink,
78787875
};
78797876

@@ -7923,7 +7920,7 @@ export class MatrixClient extends EventEmitter {
79237920
client_secret: clientSecret,
79247921
country: phoneCountry,
79257922
phone_number: phoneNumber,
7926-
send_attempt: String(sendAttempt),
7923+
send_attempt: sendAttempt?.toString(),
79277924
next_link: nextLink,
79287925
};
79297926

@@ -8388,9 +8385,9 @@ export class MatrixClient extends EventEmitter {
83888385
next_batch?: string; // eslint-disable-line camelcase
83898386
}>(undefined, Method.Get, path, {
83908387
suggested_only: String(suggestedOnly),
8391-
max_depth: String(maxDepth),
8388+
max_depth: maxDepth?.toString(),
83928389
from: fromToken,
8393-
limit: String(limit),
8390+
limit: limit?.toString(),
83948391
}, undefined, {
83958392
prefix: "/_matrix/client/unstable/org.matrix.msc2946",
83968393
}).catch(e => {

0 commit comments

Comments
 (0)