From 55d6cf7ab0abed15f9bf8b6c8d81874e0a333160 Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 16 Sep 2016 20:08:21 +0100 Subject: [PATCH 1/3] Update /publicRooms to use the new pagination API --- lib/base-apis.js | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/lib/base-apis.js b/lib/base-apis.js index dc2c6899f..c04b1d6ec 100644 --- a/lib/base-apis.js +++ b/lib/base-apis.js @@ -415,12 +415,35 @@ MatrixBaseApis.prototype.roomInitialSync = function(roomId, limit, callback) { // ========================= /** + * @param {string} options.server The remote server to query for the room list. + * Optional. If unspecified, get the local home + * server's public room list. + * @param {number} options.limit Maximum number of entries to return + * @param {string} options.since Token to paginate from + * @param {object} options.filter Filter parameters + * @param {string} options.filter.generic_search_term String to search for * @param {module:client.callback} callback Optional. * @return {module:client.Promise} Resolves: TODO * @return {module:http-api.MatrixError} Rejects: with an error response. */ -MatrixBaseApis.prototype.publicRooms = function(callback) { - return this._http.authedRequest(callback, "GET", "/publicRooms"); +MatrixBaseApis.prototype.publicRooms = function(options, callback) { + if (typeof(options) == 'function') { + callback = options; + options = {}; + } + if (options === undefined) { + options = {}; + } + + var query_params = {}; + if (options.server) { + query_params.server = options.server; + delete options.server; + } + + return this._http.authedRequest( + callback, "POST", "/publicRooms", query_params, options + ); }; /** From 8259f088825f5c14899869d7930332fbdd116031 Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 16 Sep 2016 20:11:00 +0100 Subject: [PATCH 2/3] Add changelog entry to note we've broken publicRooms on older synapses --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d445c22a..72bfb93b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +Unreleased Changed: +=================== + +**BREAKING CHANGES**: + * /publicRooms now uses the new POST API. This is only present + on synapse versions 0.18.0-rc1 and later. + Changes in [0.5.6](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v0.5.6) (2016-08-28) ================================================================================================ [Full Changelog](https://github.com/matrix-org/matrix-js-sdk/compare/v0.5.5...v0.5.6) From 0d51fad805052fc577c61a13505b7b893185915d Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 16 Sep 2016 23:23:25 +0100 Subject: [PATCH 3/3] Make js-sdk compatible with older synapses Use GET API if no params given. Revert changelog entry since it now doesn't break older synapses. --- CHANGELOG.md | 7 ------- lib/base-apis.js | 10 +++++++--- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 72bfb93b2..0d445c22a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,3 @@ -Unreleased Changed: -=================== - -**BREAKING CHANGES**: - * /publicRooms now uses the new POST API. This is only present - on synapse versions 0.18.0-rc1 and later. - Changes in [0.5.6](https://github.com/matrix-org/matrix-js-sdk/releases/tag/v0.5.6) (2016-08-28) ================================================================================================ [Full Changelog](https://github.com/matrix-org/matrix-js-sdk/compare/v0.5.5...v0.5.6) diff --git a/lib/base-apis.js b/lib/base-apis.js index c04b1d6ec..ed0bffbe2 100644 --- a/lib/base-apis.js +++ b/lib/base-apis.js @@ -441,9 +441,13 @@ MatrixBaseApis.prototype.publicRooms = function(options, callback) { delete options.server; } - return this._http.authedRequest( - callback, "POST", "/publicRooms", query_params, options - ); + if (Object.keys(options).length === 0 && Object.keys(query_params).length === 0) { + return this._http.authedRequest(callback, "GET", "/publicRooms"); + } else { + return this._http.authedRequest( + callback, "POST", "/publicRooms", query_params, options + ); + } }; /**