1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-26 17:03:12 +03:00

Fix sending undefined query args to Synapse (#2070)

This commit is contained in:
Michael Telatynski
2021-12-14 17:38:28 +00:00
committed by GitHub
parent e4703989fe
commit df11a9e832

View File

@@ -4285,7 +4285,7 @@ export class MatrixClient extends EventEmitter {
const resp = this.http.authedRequest( const resp = this.http.authedRequest(
callback, Method.Get, "/preview_url", { callback, Method.Get, "/preview_url", {
url, url,
ts: String(ts), ts: ts.toString(),
}, undefined, { }, undefined, {
prefix: PREFIX_MEDIA_R0, prefix: PREFIX_MEDIA_R0,
}, },
@@ -5016,18 +5016,16 @@ export class MatrixClient extends EventEmitter {
public createMessagesRequest( public createMessagesRequest(
roomId: string, roomId: string,
fromToken: string, fromToken: string,
limit: number, limit = 30,
dir: Direction, dir: Direction,
timelineFilter?: Filter, timelineFilter?: Filter,
): Promise<IMessagesResponse> { ): Promise<IMessagesResponse> {
const path = utils.encodeUri("/rooms/$roomId/messages", { $roomId: roomId }); const path = utils.encodeUri("/rooms/$roomId/messages", { $roomId: roomId });
if (limit === undefined) {
limit = 30;
}
const params: Record<string, string> = { const params: Record<string, string> = {
from: fromToken, from: fromToken,
limit: String(limit), limit: limit.toString(),
dir: dir, dir,
}; };
let filter = null; let filter = null;
@@ -6956,13 +6954,12 @@ export class MatrixClient extends EventEmitter {
callback = limit as any as Callback; // legacy callback = limit as any as Callback; // legacy
limit = undefined; limit = undefined;
} }
const path = utils.encodeUri("/rooms/$roomId/initialSync", const path = utils.encodeUri("/rooms/$roomId/initialSync",
{ $roomId: roomId }, { $roomId: roomId },
); );
if (!limit) {
limit = 30; return this.http.authedRequest(callback, Method.Get, path, { limit: limit?.toString() ?? "30" });
}
return this.http.authedRequest(callback, Method.Get, path, { limit: String(limit) });
} }
/** /**
@@ -7873,7 +7870,7 @@ export class MatrixClient extends EventEmitter {
const params = { const params = {
client_secret: clientSecret, client_secret: clientSecret,
email: email, email: email,
send_attempt: String(sendAttempt), send_attempt: sendAttempt?.toString(),
next_link: nextLink, next_link: nextLink,
}; };
@@ -7923,7 +7920,7 @@ export class MatrixClient extends EventEmitter {
client_secret: clientSecret, client_secret: clientSecret,
country: phoneCountry, country: phoneCountry,
phone_number: phoneNumber, phone_number: phoneNumber,
send_attempt: String(sendAttempt), send_attempt: sendAttempt?.toString(),
next_link: nextLink, next_link: nextLink,
}; };
@@ -8388,9 +8385,9 @@ export class MatrixClient extends EventEmitter {
next_batch?: string; // eslint-disable-line camelcase next_batch?: string; // eslint-disable-line camelcase
}>(undefined, Method.Get, path, { }>(undefined, Method.Get, path, {
suggested_only: String(suggestedOnly), suggested_only: String(suggestedOnly),
max_depth: String(maxDepth), max_depth: maxDepth?.toString(),
from: fromToken, from: fromToken,
limit: String(limit), limit: limit?.toString(),
}, undefined, { }, undefined, {
prefix: "/_matrix/client/unstable/org.matrix.msc2946", prefix: "/_matrix/client/unstable/org.matrix.msc2946",
}).catch(e => { }).catch(e => {