From b004d1602d0fb4a4553d0ff66988cc58ba23f34c Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Mon, 29 Jul 2019 12:25:38 +0100
Subject: [PATCH] Remove deprecated authedRequestWithPrefix and
requestWithPrefix replacing as documented with authedRequest
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---
spec/unit/matrix-client.spec.js | 8 +---
src/base-apis.js | 6 ++-
src/client.js | 12 ++++--
src/http-api.js | 70 ---------------------------------
4 files changed, 13 insertions(+), 83 deletions(-)
diff --git a/spec/unit/matrix-client.spec.js b/spec/unit/matrix-client.spec.js
index 5d870754d..029ae1bb5 100644
--- a/spec/unit/matrix-client.spec.js
+++ b/spec/unit/matrix-client.spec.js
@@ -154,12 +154,9 @@ describe("MatrixClient", function() {
});
// FIXME: We shouldn't be yanking _http like this.
client._http = [
- "authedRequest", "authedRequestWithPrefix", "getContentUri",
- "request", "requestWithPrefix", "uploadContent",
+ "authedRequest", "getContentUri", "request", "uploadContent",
].reduce((r, k) => { r[k] = expect.createSpy(); return r; }, {});
client._http.authedRequest.andCall(httpReq);
- client._http.authedRequestWithPrefix.andCall(httpReq);
- client._http.requestWithPrefix.andCall(httpReq);
client._http.request.andCall(httpReq);
// set reasonable working defaults
@@ -181,9 +178,6 @@ describe("MatrixClient", function() {
client._http.authedRequest.andCall(function() {
return Promise.defer().promise;
});
- client._http.authedRequestWithPrefix.andCall(function() {
- return Promise.defer().promise;
- });
});
it("should not POST /filter if a matching filter already exists", async function() {
diff --git a/src/base-apis.js b/src/base-apis.js
index 83cd35b16..1d1ffb54a 100644
--- a/src/base-apis.js
+++ b/src/base-apis.js
@@ -475,8 +475,10 @@ MatrixBaseApis.prototype.fetchRelations =
$relationType: relationType,
$eventType: eventType,
});
- const response = await this._http.authedRequestWithPrefix(
- undefined, "GET", path, null, null, httpApi.PREFIX_UNSTABLE,
+ const response = await this._http.authedRequest(
+ undefined, "GET", path, null, null, {
+ prefix: httpApi.PREFIX_UNSTABLE,
+ },
);
return response;
};
diff --git a/src/client.js b/src/client.js
index df673885c..76b50b491 100644
--- a/src/client.js
+++ b/src/client.js
@@ -1369,8 +1369,10 @@ MatrixClient.prototype.getGroups = function() {
* @return {module:client.Promise} Resolves with an object containing the config.
*/
MatrixClient.prototype.getMediaConfig = function(callback) {
- return this._http.authedRequestWithPrefix(
- callback, "GET", "/config", undefined, undefined, httpApi.PREFIX_MEDIA_R0,
+ return this._http.authedRequest(
+ callback, "GET", "/config", undefined, undefined, {
+ prefix: httpApi.PREFIX_MEDIA_R0,
+ },
);
};
@@ -2275,11 +2277,13 @@ MatrixClient.prototype.getUrlPreview = function(url, ts, callback) {
}
const self = this;
- return this._http.authedRequestWithPrefix(
+ return this._http.authedRequest(
callback, "GET", "/preview_url", {
url: url,
ts: ts,
- }, undefined, httpApi.PREFIX_MEDIA_R0,
+ }, undefined, {
+ prefix: httpApi.PREFIX_MEDIA_R0,
+ },
).then(function(response) {
// TODO: expire cache occasionally
self.urlPreviewCache[key] = response;
diff --git a/src/http-api.js b/src/http-api.js
index 374c00644..ef95527ab 100644
--- a/src/http-api.js
+++ b/src/http-api.js
@@ -531,76 +531,6 @@ module.exports.MatrixHttpApi.prototype = {
);
},
- /**
- * Perform an authorised request to the homeserver with a specific path
- * prefix which overrides the default for this call only. Useful for hitting
- * different Matrix Client-Server versions.
- * @param {Function} callback Optional. The callback to invoke on
- * success/failure. See the promise return values for more information.
- * @param {string} method The HTTP method e.g. "GET".
- * @param {string} path The HTTP path after the supplied prefix e.g.
- * "/createRoom".
- * @param {Object} queryParams A dict of query params (these will NOT be
- * urlencoded).
- * @param {Object} data The HTTP JSON body.
- * @param {string} prefix The full prefix to use e.g.
- * "/_matrix/client/v2_alpha".
- * @param {Number=} localTimeoutMs The maximum amount of time to wait before
- * timing out the request. If not specified, there is no timeout.
- * @return {module:client.Promise} Resolves to {data: {Object},
- * headers: {Object}, code: {Number}}
.
- * If onlyData
is set, this will resolve to the data
- * object only.
- * @return {module:http-api.MatrixError} Rejects with an error if a problem
- * occurred. This includes network problems and Matrix-specific error JSON.
- *
- * @deprecated prefer authedRequest with opts.prefix
- */
- authedRequestWithPrefix: function(callback, method, path, queryParams, data,
- prefix, localTimeoutMs) {
- return this.authedRequest(
- callback, method, path, queryParams, data, {
- localTimeoutMs: localTimeoutMs,
- prefix: prefix,
- },
- );
- },
-
- /**
- * Perform a request to the homeserver without any credentials but with a
- * specific path prefix which overrides the default for this call only.
- * Useful for hitting different Matrix Client-Server versions.
- * @param {Function} callback Optional. The callback to invoke on
- * success/failure. See the promise return values for more information.
- * @param {string} method The HTTP method e.g. "GET".
- * @param {string} path The HTTP path after the supplied prefix e.g.
- * "/createRoom".
- * @param {Object} queryParams A dict of query params (these will NOT be
- * urlencoded).
- * @param {Object} data The HTTP JSON body.
- * @param {string} prefix The full prefix to use e.g.
- * "/_matrix/client/v2_alpha".
- * @param {Number=} localTimeoutMs The maximum amount of time to wait before
- * timing out the request. If not specified, there is no timeout.
- * @return {module:client.Promise} Resolves to {data: {Object},
- * headers: {Object}, code: {Number}}
.
- * If onlyData
is set, this will resolve to the data
- * object only.
- * @return {module:http-api.MatrixError} Rejects with an error if a problem
- * occurred. This includes network problems and Matrix-specific error JSON.
- *
- * @deprecated prefer request with opts.prefix
- */
- requestWithPrefix: function(callback, method, path, queryParams, data, prefix,
- localTimeoutMs) {
- return this.request(
- callback, method, path, queryParams, data, {
- localTimeoutMs: localTimeoutMs,
- prefix: prefix,
- },
- );
- },
-
/**
* Perform a request to an arbitrary URL.
* @param {Function} callback Optional. The callback to invoke on