1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-26 17:03:12 +03:00

eslint ---fix for prefer-const

This commit is contained in:
David Baker
2017-01-19 17:42:10 +00:00
parent 9b354ba99e
commit 7bca05af64
60 changed files with 1732 additions and 1732 deletions

View File

@@ -22,8 +22,8 @@ limitations under the License.
* @module base-apis
*/
let httpApi = require("./http-api");
let utils = require("./utils");
const httpApi = require("./http-api");
const utils = require("./utils");
/**
* Low-level wrappers for the Matrix APIs
@@ -60,7 +60,7 @@ function MatrixBaseApis(opts) {
this.baseUrl = opts.baseUrl;
this.idBaseUrl = opts.idBaseUrl;
let httpOpts = {
const httpOpts = {
baseUrl: opts.baseUrl,
idBaseUrl: opts.idBaseUrl,
accessToken: opts.accessToken,
@@ -142,7 +142,7 @@ MatrixBaseApis.prototype.register = function(
auth.session = sessionId;
}
let params = {
const params = {
auth: auth,
};
if (username !== undefined && username !== null) {
@@ -183,7 +183,7 @@ MatrixBaseApis.prototype.registerGuest = function(opts, callback) {
* @return {module:http-api.MatrixError} Rejects: with an error response.
*/
MatrixBaseApis.prototype.registerRequest = function(data, kind, callback) {
let params = {};
const params = {};
if (kind) {
params.kind = kind;
}
@@ -210,7 +210,7 @@ MatrixBaseApis.prototype.loginFlows = function(callback) {
* @return {module:http-api.MatrixError} Rejects: with an error response.
*/
MatrixBaseApis.prototype.login = function(loginType, data, callback) {
let login_data = {
const login_data = {
type: loginType,
};
@@ -318,7 +318,7 @@ MatrixBaseApis.prototype.deactivateAccount = function(auth, callback) {
* @return {string} HS URL to hit to for the fallback interface
*/
MatrixBaseApis.prototype.getFallbackAuthUrl = function(loginType, authSessionId) {
let path = utils.encodeUri("/auth/$loginType/fallback/web", {
const path = utils.encodeUri("/auth/$loginType/fallback/web", {
$loginType: loginType,
});
@@ -358,7 +358,7 @@ MatrixBaseApis.prototype.createRoom = function(options, callback) {
* @return {module:http-api.MatrixError} Rejects: with an error response.
*/
MatrixBaseApis.prototype.roomState = function(roomId, callback) {
let path = utils.encodeUri("/rooms/$roomId/state", {$roomId: roomId});
const path = utils.encodeUri("/rooms/$roomId/state", {$roomId: roomId});
return this._http.authedRequest(callback, "GET", path);
};
@@ -372,7 +372,7 @@ MatrixBaseApis.prototype.roomState = function(roomId, callback) {
* @return {module:http-api.MatrixError} Rejects: with an error response.
*/
MatrixBaseApis.prototype.getStateEvent = function(roomId, eventType, stateKey, callback) {
let pathParams = {
const pathParams = {
$roomId: roomId,
$eventType: eventType,
$stateKey: stateKey,
@@ -397,7 +397,7 @@ MatrixBaseApis.prototype.getStateEvent = function(roomId, eventType, stateKey, c
*/
MatrixBaseApis.prototype.sendStateEvent = function(roomId, eventType, content, stateKey,
callback) {
let pathParams = {
const pathParams = {
$roomId: roomId,
$eventType: eventType,
$stateKey: stateKey,
@@ -419,7 +419,7 @@ MatrixBaseApis.prototype.sendStateEvent = function(roomId, eventType, content, s
* @return {module:http-api.MatrixError} Rejects: with an error response.
*/
MatrixBaseApis.prototype.redactEvent = function(roomId, eventId, callback) {
let path = utils.encodeUri("/rooms/$roomId/redact/$eventId", {
const path = utils.encodeUri("/rooms/$roomId/redact/$eventId", {
$roomId: roomId,
$eventId: eventId,
});
@@ -437,7 +437,7 @@ MatrixBaseApis.prototype.roomInitialSync = function(roomId, limit, callback) {
if (utils.isFunction(limit)) {
callback = limit; limit = undefined;
}
let path = utils.encodeUri("/rooms/$roomId/initialSync",
const path = utils.encodeUri("/rooms/$roomId/initialSync",
{$roomId: roomId}
);
if (!limit) {
@@ -474,7 +474,7 @@ MatrixBaseApis.prototype.publicRooms = function(options, callback) {
options = {};
}
let query_params = {};
const query_params = {};
if (options.server) {
query_params.server = options.server;
delete options.server;
@@ -498,10 +498,10 @@ MatrixBaseApis.prototype.publicRooms = function(options, callback) {
* @return {module:http-api.MatrixError} Rejects: with an error response.
*/
MatrixBaseApis.prototype.createAlias = function(alias, roomId, callback) {
let path = utils.encodeUri("/directory/room/$alias", {
const path = utils.encodeUri("/directory/room/$alias", {
$alias: alias,
});
let data = {
const data = {
room_id: roomId,
};
return this._http.authedRequest(
@@ -518,7 +518,7 @@ MatrixBaseApis.prototype.createAlias = function(alias, roomId, callback) {
* @return {module:http-api.MatrixError} Rejects: with an error response.
*/
MatrixBaseApis.prototype.deleteAlias = function(alias, callback) {
let path = utils.encodeUri("/directory/room/$alias", {
const path = utils.encodeUri("/directory/room/$alias", {
$alias: alias,
});
return this._http.authedRequest(
@@ -535,7 +535,7 @@ MatrixBaseApis.prototype.deleteAlias = function(alias, callback) {
*/
MatrixBaseApis.prototype.getRoomIdForAlias = function(alias, callback) {
// TODO: deprecate this or resolveRoomAlias
let path = utils.encodeUri("/directory/room/$alias", {
const path = utils.encodeUri("/directory/room/$alias", {
$alias: alias,
});
return this._http.authedRequest(
@@ -551,7 +551,7 @@ MatrixBaseApis.prototype.getRoomIdForAlias = function(alias, callback) {
*/
MatrixBaseApis.prototype.resolveRoomAlias = function(roomAlias, callback) {
// TODO: deprecate this or getRoomIdForAlias
let path = utils.encodeUri("/directory/room/$alias", {$alias: roomAlias});
const path = utils.encodeUri("/directory/room/$alias", {$alias: roomAlias});
return this._http.request(callback, "GET", path);
};
@@ -564,7 +564,7 @@ MatrixBaseApis.prototype.resolveRoomAlias = function(roomAlias, callback) {
*/
MatrixBaseApis.prototype.getRoomDirectoryVisibility =
function(roomId, callback) {
let path = utils.encodeUri("/directory/list/room/$roomId", {
const path = utils.encodeUri("/directory/list/room/$roomId", {
$roomId: roomId,
});
return this._http.authedRequest(callback, "GET", path);
@@ -582,7 +582,7 @@ MatrixBaseApis.prototype.getRoomDirectoryVisibility =
*/
MatrixBaseApis.prototype.setRoomDirectoryVisibility =
function(roomId, visibility, callback) {
let path = utils.encodeUri("/directory/list/room/$roomId", {
const path = utils.encodeUri("/directory/list/room/$roomId", {
$roomId: roomId,
});
return this._http.authedRequest(
@@ -605,7 +605,7 @@ MatrixBaseApis.prototype.setRoomDirectoryVisibility =
*/
MatrixBaseApis.prototype.setRoomDirectoryVisibilityAppService =
function(networkId, roomId, visibility, callback) {
let path = utils.encodeUri("/directory/list/appservice/$networkId/$roomId", {
const path = utils.encodeUri("/directory/list/appservice/$networkId/$roomId", {
$networkId: networkId,
$roomId: roomId,
});
@@ -692,7 +692,7 @@ MatrixBaseApis.prototype.getProfileInfo = function(userId, info, callback) {
callback = info; info = undefined;
}
let path = info ?
const path = info ?
utils.encodeUri("/profile/$userId/$info",
{ $userId: userId, $info: info }) :
utils.encodeUri("/profile/$userId",
@@ -710,7 +710,7 @@ MatrixBaseApis.prototype.getProfileInfo = function(userId, info, callback) {
* @return {module:http-api.MatrixError} Rejects: with an error response.
*/
MatrixBaseApis.prototype.getThreePids = function(callback) {
let path = "/account/3pid";
const path = "/account/3pid";
return this._http.authedRequest(
callback, "GET", path, undefined, undefined
);
@@ -724,8 +724,8 @@ MatrixBaseApis.prototype.getThreePids = function(callback) {
* @return {module:http-api.MatrixError} Rejects: with an error response.
*/
MatrixBaseApis.prototype.addThreePid = function(creds, bind, callback) {
let path = "/account/3pid";
let data = {
const path = "/account/3pid";
const data = {
'threePidCreds': creds,
'bind': bind,
};
@@ -743,8 +743,8 @@ MatrixBaseApis.prototype.addThreePid = function(creds, bind, callback) {
* @return {module:http-api.MatrixError} Rejects: with an error response.
*/
MatrixBaseApis.prototype.deleteThreePid = function(medium, address) {
let path = "/account/3pid/delete";
let data = {
const path = "/account/3pid/delete";
const data = {
'medium': medium,
'address': address,
};
@@ -762,8 +762,8 @@ MatrixBaseApis.prototype.deleteThreePid = function(medium, address) {
* @return {module:http-api.MatrixError} Rejects: with an error response.
*/
MatrixBaseApis.prototype.setPassword = function(authDict, newPassword, callback) {
let path = "/account/password";
let data = {
const path = "/account/password";
const data = {
'auth': authDict,
'new_password': newPassword,
};
@@ -783,7 +783,7 @@ MatrixBaseApis.prototype.setPassword = function(authDict, newPassword, callback)
* @return {module:http-api.MatrixError} Rejects: with an error response.
*/
MatrixBaseApis.prototype.getDevices = function() {
let path = "/devices";
const path = "/devices";
return this._http.authedRequestWithPrefix(
undefined, "GET", path, undefined, undefined,
httpApi.PREFIX_UNSTABLE
@@ -799,7 +799,7 @@ MatrixBaseApis.prototype.getDevices = function() {
* @return {module:http-api.MatrixError} Rejects: with an error response.
*/
MatrixBaseApis.prototype.setDeviceDetails = function(device_id, body) {
let path = utils.encodeUri("/devices/$device_id", {
const path = utils.encodeUri("/devices/$device_id", {
$device_id: device_id,
});
@@ -819,11 +819,11 @@ MatrixBaseApis.prototype.setDeviceDetails = function(device_id, body) {
* @return {module:http-api.MatrixError} Rejects: with an error response.
*/
MatrixBaseApis.prototype.deleteDevice = function(device_id, auth) {
let path = utils.encodeUri("/devices/$device_id", {
const path = utils.encodeUri("/devices/$device_id", {
$device_id: device_id,
});
let body = {};
const body = {};
if (auth) {
body.auth = auth;
@@ -847,7 +847,7 @@ MatrixBaseApis.prototype.deleteDevice = function(device_id, auth) {
* @return {module:http-api.MatrixError} Rejects: with an error response.
*/
MatrixBaseApis.prototype.getPushers = function(callback) {
let path = "/pushers";
const path = "/pushers";
return this._http.authedRequest(
callback, "GET", path, undefined, undefined
);
@@ -862,7 +862,7 @@ MatrixBaseApis.prototype.getPushers = function(callback) {
* @return {module:http-api.MatrixError} Rejects: with an error response.
*/
MatrixBaseApis.prototype.setPusher = function(pusher, callback) {
let path = "/pushers/set";
const path = "/pushers/set";
return this._http.authedRequest(
callback, "POST", path, null, pusher
);
@@ -888,7 +888,7 @@ MatrixBaseApis.prototype.getPushRules = function(callback) {
*/
MatrixBaseApis.prototype.addPushRule = function(scope, kind, ruleId, body, callback) {
// NB. Scope not uri encoded because devices need the '/'
let path = utils.encodeUri("/pushrules/" + scope + "/$kind/$ruleId", {
const path = utils.encodeUri("/pushrules/" + scope + "/$kind/$ruleId", {
$kind: kind,
$ruleId: ruleId,
});
@@ -907,7 +907,7 @@ MatrixBaseApis.prototype.addPushRule = function(scope, kind, ruleId, body, callb
*/
MatrixBaseApis.prototype.deletePushRule = function(scope, kind, ruleId, callback) {
// NB. Scope not uri encoded because devices need the '/'
let path = utils.encodeUri("/pushrules/" + scope + "/$kind/$ruleId", {
const path = utils.encodeUri("/pushrules/" + scope + "/$kind/$ruleId", {
$kind: kind,
$ruleId: ruleId,
});
@@ -926,7 +926,7 @@ MatrixBaseApis.prototype.deletePushRule = function(scope, kind, ruleId, callback
*/
MatrixBaseApis.prototype.setPushRuleEnabled = function(scope, kind,
ruleId, enabled, callback) {
let path = utils.encodeUri("/pushrules/" + scope + "/$kind/$ruleId/enabled", {
const path = utils.encodeUri("/pushrules/" + scope + "/$kind/$ruleId/enabled", {
$kind: kind,
$ruleId: ruleId,
});
@@ -947,7 +947,7 @@ MatrixBaseApis.prototype.setPushRuleEnabled = function(scope, kind,
*/
MatrixBaseApis.prototype.setPushRuleActions = function(scope, kind,
ruleId, actions, callback) {
let path = utils.encodeUri("/pushrules/" + scope + "/$kind/$ruleId/actions", {
const path = utils.encodeUri("/pushrules/" + scope + "/$kind/$ruleId/actions", {
$kind: kind,
$ruleId: ruleId,
});
@@ -970,7 +970,7 @@ MatrixBaseApis.prototype.setPushRuleActions = function(scope, kind,
* @return {module:http-api.MatrixError} Rejects: with an error response.
*/
MatrixBaseApis.prototype.search = function(opts, callback) {
let queryparams = {};
const queryparams = {};
if (opts.next_batch) {
queryparams.next_batch = opts.next_batch;
}
@@ -999,7 +999,7 @@ MatrixBaseApis.prototype.search = function(opts, callback) {
*/
MatrixBaseApis.prototype.uploadKeysRequest = function(content, opts, callback) {
opts = opts || {};
let deviceId = opts.device_id;
const deviceId = opts.device_id;
let path;
if (deviceId) {
path = utils.encodeUri("/keys/upload/$deviceId", {
@@ -1024,12 +1024,12 @@ MatrixBaseApis.prototype.uploadKeysRequest = function(content, opts, callback) {
* an error response ({@link module:http-api.MatrixError}).
*/
MatrixBaseApis.prototype.downloadKeysForUsers = function(userIds, callback) {
let downloadQuery = {};
const downloadQuery = {};
for (let i = 0; i < userIds.length; ++i) {
downloadQuery[userIds[i]] = {};
}
let content = {device_keys: downloadQuery};
const content = {device_keys: downloadQuery};
return this._http.authedRequestWithPrefix(
callback, "POST", "/keys/query", undefined, content,
httpApi.PREFIX_UNSTABLE
@@ -1047,20 +1047,20 @@ MatrixBaseApis.prototype.downloadKeysForUsers = function(userIds, callback) {
* an error response ({@link module:http-api.MatrixError}).
*/
MatrixBaseApis.prototype.claimOneTimeKeys = function(devices, key_algorithm) {
let queries = {};
const queries = {};
if (key_algorithm === undefined) {
key_algorithm = "signed_curve25519";
}
for (let i = 0; i < devices.length; ++i) {
let userId = devices[i][0];
let deviceId = devices[i][1];
let query = queries[userId] || {};
const userId = devices[i][0];
const deviceId = devices[i][1];
const query = queries[userId] || {};
queries[userId] = query;
query[deviceId] = key_algorithm;
}
let content = {one_time_keys: queries};
const content = {one_time_keys: queries};
return this._http.authedRequestWithPrefix(
undefined, "POST", "/keys/claim", undefined, content,
httpApi.PREFIX_UNSTABLE
@@ -1093,7 +1093,7 @@ MatrixBaseApis.prototype.claimOneTimeKeys = function(devices, key_algorithm) {
*/
MatrixBaseApis.prototype.requestEmailToken = function(email, clientSecret,
sendAttempt, nextLink, callback) {
let params = {
const params = {
client_secret: clientSecret,
email: email,
send_attempt: sendAttempt,
@@ -1117,7 +1117,7 @@ MatrixBaseApis.prototype.requestEmailToken = function(email, clientSecret,
* @return {module:http-api.MatrixError} Rejects: with an error response.
*/
MatrixBaseApis.prototype.lookupThreePid = function(medium, address, callback) {
let params = {
const params = {
medium: medium,
address: address,
};
@@ -1144,12 +1144,12 @@ MatrixBaseApis.prototype.lookupThreePid = function(medium, address, callback) {
MatrixBaseApis.prototype.sendToDevice = function(
eventType, contentMap, txnId
) {
let path = utils.encodeUri("/sendToDevice/$eventType/$txnId", {
const path = utils.encodeUri("/sendToDevice/$eventType/$txnId", {
$eventType: eventType,
$txnId: txnId ? txnId : this.makeTxnId(),
});
let body = {
const body = {
messages: contentMap,
};
@@ -1183,7 +1183,7 @@ MatrixBaseApis.prototype.getThirdpartyProtocols = function() {
* @return {module:client.Promise} Resolves to the result object
*/
MatrixBaseApis.prototype.getThirdpartyLocation = function(protocol, params) {
let path = utils.encodeUri("/thirdparty/location/$protocol", {
const path = utils.encodeUri("/thirdparty/location/$protocol", {
$protocol: protocol,
});