You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-08-19 16:42:09 +03:00
closure linting errors
This commit is contained in:
@@ -1,15 +1,20 @@
|
|||||||
var micromatch = require("micromatch");
|
var micromatch = require("micromatch");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a Push Processor.
|
||||||
|
* @constructor
|
||||||
|
* @param {Object} client The Matrix client object to use
|
||||||
|
*/
|
||||||
module.exports = function(client) {
|
module.exports = function(client) {
|
||||||
|
var escapeRegExp = function(string) {
|
||||||
|
|
||||||
var escapeRegExp = function(string){
|
|
||||||
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||||
};
|
};
|
||||||
|
|
||||||
var matchingRuleFromKindSet = function(ev, kindset, device) {
|
var matchingRuleFromKindSet = function(ev, kindset, device) {
|
||||||
var rulekinds_in_order = ['override', 'content', 'room', 'sender', 'underride'];
|
var rulekinds_in_order = ['override', 'content', 'room', 'sender', 'underride'];
|
||||||
for (var ruleKindIndex = 0; ruleKindIndex < rulekinds_in_order.length; ++ruleKindIndex) {
|
for (var ruleKindIndex = 0;
|
||||||
|
ruleKindIndex < rulekinds_in_order.length;
|
||||||
|
++ruleKindIndex) {
|
||||||
var kind = rulekinds_in_order[ruleKindIndex];
|
var kind = rulekinds_in_order[ruleKindIndex];
|
||||||
var ruleset = kindset[kind];
|
var ruleset = kindset[kind];
|
||||||
|
|
||||||
@@ -68,7 +73,7 @@ module.exports = function(client) {
|
|||||||
if (device) {
|
if (device) {
|
||||||
rawrule.conditions.push({
|
rawrule.conditions.push({
|
||||||
'kind': 'device',
|
'kind': 'device',
|
||||||
'profile_tag': device,
|
'profile_tag': device
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return rawrule;
|
return rawrule;
|
||||||
@@ -91,7 +96,9 @@ module.exports = function(client) {
|
|||||||
"contains_display_name": eventFulfillsDisplayNameCondition,
|
"contains_display_name": eventFulfillsDisplayNameCondition,
|
||||||
"room_member_count": eventFulfillsRoomMemberCountCondition
|
"room_member_count": eventFulfillsRoomMemberCountCondition
|
||||||
};
|
};
|
||||||
if (condition_functions[cond.kind]) { return condition_functions[cond.kind](cond, ev); }
|
if (condition_functions[cond.kind]) {
|
||||||
|
return condition_functions[cond.kind](cond, ev);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -126,12 +133,14 @@ module.exports = function(client) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var eventFulfillsDisplayNameCondition = function(cond, ev) {
|
var eventFulfillsDisplayNameCondition = function(cond, ev) {
|
||||||
if (!ev.content || ! ev.content.body || typeof ev.content.body != 'string') { return false; }
|
if (!ev.content || ! ev.content.body || typeof ev.content.body != 'string') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
var room = client.getRoom(ev.room_id);
|
var room = client.getRoom(ev.room_id);
|
||||||
var displayName = room.currentState.getMember(client.credentials.userId).name;
|
var displayName = room.currentState.getMember(client.credentials.userId).name;
|
||||||
|
|
||||||
var pat = new RegExp("\\b"+escapeRegExp(displayName)+"\\b", 'i');
|
var pat = new RegExp("\\b" + escapeRegExp(displayName) + "\\b", 'i');
|
||||||
return ev.content.body.search(pat) > -1;
|
return ev.content.body.search(pat) > -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -143,7 +152,8 @@ module.exports = function(client) {
|
|||||||
var val = valueForDottedKey(cond.key, ev);
|
var val = valueForDottedKey(cond.key, ev);
|
||||||
if (!val || typeof val != 'string') { return false; }
|
if (!val || typeof val != 'string') { return false; }
|
||||||
|
|
||||||
// Supportting ! in globs would mean figuring out when we don't want to use things as a regex, like room IDs
|
// Supportting ! in globs would mean figuring out when we
|
||||||
|
// don't want to use things as a regex, like room IDs
|
||||||
var pat = cond.pattern.replace("!", "\\!");
|
var pat = cond.pattern.replace("!", "\\!");
|
||||||
|
|
||||||
if (cond.key == 'content.body') {
|
if (cond.key == 'content.body') {
|
||||||
|
Reference in New Issue
Block a user