Merge pull request #211 from matrix-org/dbkr/public_rooms_paginate

Support /publicRooms pagination
This commit is contained in:
Matthew Hodgson
2016-09-17 01:24:40 +01:00
committed by GitHub
+29 -2
View File
@@ -415,12 +415,39 @@ 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;
}
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
);
}
};
/**