You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-08-16 18:21:59 +03:00
Tidy up, add deps and add a few more calls.
This commit is contained in:
@@ -38,10 +38,34 @@ var init = function(exports){
|
||||
return this.credentials.accessToken != undefined;
|
||||
},
|
||||
|
||||
// Room operations
|
||||
// ===============
|
||||
|
||||
createRoom: function(options, callback) {
|
||||
// valid options include: room_alias_name, visibility, invite
|
||||
return this._doAuthedRequest(
|
||||
callback, "POST", "/createRoom", undefined, options
|
||||
);
|
||||
},
|
||||
|
||||
// Public (non-authed) operations
|
||||
// ==============================
|
||||
|
||||
publicRooms: function(callback) {
|
||||
return this._doRequest(callback, "GET", "/publicRooms");
|
||||
},
|
||||
|
||||
registerFlows: function(callback) {
|
||||
return this._doRequest(callback, "GET", "/register");
|
||||
},
|
||||
|
||||
loginFlows: function(callback) {
|
||||
return this._doRequest(callback, "GET", "/login");
|
||||
},
|
||||
|
||||
// Syncing operations
|
||||
// ==================
|
||||
|
||||
initialSync: function(limit, callback) {
|
||||
var params = {
|
||||
limit: limit
|
||||
@@ -51,6 +75,9 @@ var init = function(exports){
|
||||
);
|
||||
},
|
||||
|
||||
// Internals
|
||||
// =========
|
||||
|
||||
_doAuthedRequest: function(callback, method, path, params, data) {
|
||||
if (!params) { params = {}; }
|
||||
params.access_token = this.credentials.accessToken;
|
||||
@@ -61,7 +88,7 @@ var init = function(exports){
|
||||
var fullUri = this.credentials.baseUrl + PREFIX + path;
|
||||
if (!params) { params = {}; }
|
||||
|
||||
request(
|
||||
return request(
|
||||
{
|
||||
uri: fullUri,
|
||||
method: method,
|
||||
@@ -102,19 +129,6 @@ var init = function(exports){
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
exports.test = function(){
|
||||
request({
|
||||
uri: "http://localhost:8008/_matrix/client/api/v1/publicRooms",
|
||||
method: "GET",
|
||||
withCredentials: false,
|
||||
},
|
||||
function(err, response, body) {
|
||||
console.log(body);
|
||||
});
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
if (typeof exports === 'undefined') {
|
||||
|
Reference in New Issue
Block a user