1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-08-07 23:02:56 +03:00

Remove deprecated authedRequestWithPrefix and requestWithPrefix

replacing as documented with authedRequest

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski
2019-07-29 12:25:38 +01:00
parent 6cca73b999
commit b004d1602d
4 changed files with 13 additions and 83 deletions

View File

@@ -154,12 +154,9 @@ describe("MatrixClient", function() {
}); });
// FIXME: We shouldn't be yanking _http like this. // FIXME: We shouldn't be yanking _http like this.
client._http = [ client._http = [
"authedRequest", "authedRequestWithPrefix", "getContentUri", "authedRequest", "getContentUri", "request", "uploadContent",
"request", "requestWithPrefix", "uploadContent",
].reduce((r, k) => { r[k] = expect.createSpy(); return r; }, {}); ].reduce((r, k) => { r[k] = expect.createSpy(); return r; }, {});
client._http.authedRequest.andCall(httpReq); client._http.authedRequest.andCall(httpReq);
client._http.authedRequestWithPrefix.andCall(httpReq);
client._http.requestWithPrefix.andCall(httpReq);
client._http.request.andCall(httpReq); client._http.request.andCall(httpReq);
// set reasonable working defaults // set reasonable working defaults
@@ -181,9 +178,6 @@ describe("MatrixClient", function() {
client._http.authedRequest.andCall(function() { client._http.authedRequest.andCall(function() {
return Promise.defer().promise; 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() { it("should not POST /filter if a matching filter already exists", async function() {

View File

@@ -475,8 +475,10 @@ MatrixBaseApis.prototype.fetchRelations =
$relationType: relationType, $relationType: relationType,
$eventType: eventType, $eventType: eventType,
}); });
const response = await this._http.authedRequestWithPrefix( const response = await this._http.authedRequest(
undefined, "GET", path, null, null, httpApi.PREFIX_UNSTABLE, undefined, "GET", path, null, null, {
prefix: httpApi.PREFIX_UNSTABLE,
},
); );
return response; return response;
}; };

View File

@@ -1369,8 +1369,10 @@ MatrixClient.prototype.getGroups = function() {
* @return {module:client.Promise} Resolves with an object containing the config. * @return {module:client.Promise} Resolves with an object containing the config.
*/ */
MatrixClient.prototype.getMediaConfig = function(callback) { MatrixClient.prototype.getMediaConfig = function(callback) {
return this._http.authedRequestWithPrefix( return this._http.authedRequest(
callback, "GET", "/config", undefined, undefined, httpApi.PREFIX_MEDIA_R0, callback, "GET", "/config", undefined, undefined, {
prefix: httpApi.PREFIX_MEDIA_R0,
},
); );
}; };
@@ -2275,11 +2277,13 @@ MatrixClient.prototype.getUrlPreview = function(url, ts, callback) {
} }
const self = this; const self = this;
return this._http.authedRequestWithPrefix( return this._http.authedRequest(
callback, "GET", "/preview_url", { callback, "GET", "/preview_url", {
url: url, url: url,
ts: ts, ts: ts,
}, undefined, httpApi.PREFIX_MEDIA_R0, }, undefined, {
prefix: httpApi.PREFIX_MEDIA_R0,
},
).then(function(response) { ).then(function(response) {
// TODO: expire cache occasionally // TODO: expire cache occasionally
self.urlPreviewCache[key] = response; self.urlPreviewCache[key] = response;

View File

@@ -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 <b>after</b> 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 <code>{data: {Object},
* headers: {Object}, code: {Number}}</code>.
* If <code>onlyData</code> is set, this will resolve to the <code>data</code>
* 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 <b>after</b> 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 <code>{data: {Object},
* headers: {Object}, code: {Number}}</code>.
* If <code>onlyData</code> is set, this will resolve to the <code>data</code>
* 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. * Perform a request to an arbitrary URL.
* @param {Function} callback Optional. The callback to invoke on * @param {Function} callback Optional. The callback to invoke on