diff --git a/lib/client.js b/lib/client.js index 4475eff81..fb64ea8fe 100644 --- a/lib/client.js +++ b/lib/client.js @@ -2244,14 +2244,15 @@ MatrixClient.prototype.setPushRuleEnabled = function(scope, kind, /** * Get the room-kind push rule associated with a room. - * @return {string} roomId the id of the room. + * @param {string} scope "global" or device-specific. + * @param {string} roomId the id of the room. * @return {object} the rule or undefined. */ MatrixClient.prototype.getRoomPushRule = function(scope, roomId) { // There can be only room-kind push rule per room // and its id is the room id. if (this.pushRules) { - for (var i in this.pushRules[scope].room) { + for (var i = 0; i < this.pushRules[scope].room.length; i++) { var rule = this.pushRules[scope].room[i]; if (rule.rule_id === roomId) { return rule; @@ -2263,20 +2264,21 @@ MatrixClient.prototype.getRoomPushRule = function(scope, roomId) { /** * Set a room-kind muting push rule in a room. * The operation also updates MatrixClient.pushRules at the end. - * @return {string} roomId the id of the room. - * @return {string} mute the mute state. + * @param {string} scope "global" or device-specific. + * @param {string} roomId the id of the room. + * @param {string} mute the mute state. * @return {module:client.Promise} Resolves: result object * @return {module:http-api.MatrixError} Rejects: with an error response. */ MatrixClient.prototype.setRoomMutePushRule = function(scope, roomId, mute) { var self = this; - var deferred; + var deferred, hasDontNotifyRule; // Get the existing room-kind push rule if any var roomPushRule = this.getRoomPushRule(scope, roomId); if (roomPushRule) { if (0 <= roomPushRule.actions.indexOf("dont_notify")) { - var hasDontNotifyRule = true; + hasDontNotifyRule = true; } } @@ -2303,7 +2305,7 @@ MatrixClient.prototype.setRoomMutePushRule = function(scope, roomId, mute) { deferred2.resolve(); }, function(err) { deferred2.reject(err); - }); + }); }, function(err) { deferred2.reject(err); });