diff --git a/.eslintrc b/.eslintrc
index e216b836fcd..0dd9f5a3deb 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -76,6 +76,8 @@
"use-isnan": 2,
"valid-typeof": 2,
"linebreak-style": [2, "unix"],
+ "prefer-template": 2,
+ "template-curly-spacing": [2, "always"],
"quotes": [2, "single"],
"semi": [2, "always"],
"prefer-const": 2,
diff --git a/client/routes/router.js b/client/routes/router.js
index fb7882344f0..9d5c7e6eb9d 100644
--- a/client/routes/router.js
+++ b/client/routes/router.js
@@ -84,7 +84,7 @@ FlowRouter.route('/account/:group?', {
params.group = 'Preferences';
}
params.group = _.capitalize(params.group, true);
- BlazeLayout.render('main', { center: `account${params.group}` });
+ BlazeLayout.render('main', { center: `account${ params.group }` });
}
});
diff --git a/client/startup/roomObserve.js b/client/startup/roomObserve.js
index ea3222a1fc6..f2b6bafd8ac 100644
--- a/client/startup/roomObserve.js
+++ b/client/startup/roomObserve.js
@@ -1,13 +1,13 @@
Meteor.startup(function() {
ChatRoom.find().observe({
added(data) {
- Session.set('roomData' + data._id, data);
+ Session.set(`roomData${ data._id }`, data);
},
changed(data) {
- Session.set('roomData' + data._id, data);
+ Session.set(`roomData${ data._id }`, data);
},
removed(data) {
- Session.set('roomData' + data._id, undefined);
+ Session.set(`roomData${ data._id }`, undefined);
}
});
});
diff --git a/client/startup/unread.js b/client/startup/unread.js
index 702a826eb01..d624f08c0ed 100644
--- a/client/startup/unread.js
+++ b/client/startup/unread.js
@@ -78,6 +78,6 @@ Meteor.startup(function() {
});
}
- document.title = unread === '' ? siteName : `(${unread}) ${siteName}`;
+ document.title = unread === '' ? siteName : `(${ unread }) ${ siteName }`;
});
});
diff --git a/client/startup/usersObserve.js b/client/startup/usersObserve.js
index 76c2b4604e0..2dbddf94205 100644
--- a/client/startup/usersObserve.js
+++ b/client/startup/usersObserve.js
@@ -1,15 +1,15 @@
Meteor.startup(function() {
Meteor.users.find({}, { fields: { name: 1, username: 1, pictures: 1, status: 1, emails: 1, phone: 1, services: 1, utcOffset: 1 } }).observe({
added(user) {
- Session.set('user_' + user.username + '_status', user.status);
+ Session.set(`user_${ user.username }_status`, user.status);
RoomManager.updateUserStatus(user, user.status, user.utcOffset);
},
changed(user) {
- Session.set('user_' + user.username + '_status', user.status);
+ Session.set(`user_${ user.username }_status`, user.status);
RoomManager.updateUserStatus(user, user.status, user.utcOffset);
},
removed(user) {
- Session.set('user_' + user.username + '_status', null);
+ Session.set(`user_${ user.username }_status`, null);
RoomManager.updateUserStatus(user, 'offline', null);
}
});
diff --git a/lib/fileUpload.js b/lib/fileUpload.js
index 2c52e75f6ad..fbb006f15b7 100644
--- a/lib/fileUpload.js
+++ b/lib/fileUpload.js
@@ -5,8 +5,8 @@ if (UploadFS) {
const initFileStore = function() {
const cookie = new Cookies();
if (Meteor.isClient) {
- document.cookie = 'rc_uid=' + escape(Meteor.userId()) + '; path=/';
- document.cookie = 'rc_token=' + escape(Accounts._storedLoginToken()) + '; path=/';
+ document.cookie = `rc_uid=${ escape(Meteor.userId()) }; path=/`;
+ document.cookie = `rc_token=${ escape(Accounts._storedLoginToken()) }; path=/`;
}
Meteor.fileStore = new UploadFS.store.GridFS({
diff --git a/packages/meteor-accounts-saml/saml_client.js b/packages/meteor-accounts-saml/saml_client.js
index fef7b34d691..85502e72ad7 100644
--- a/packages/meteor-accounts-saml/saml_client.js
+++ b/packages/meteor-accounts-saml/saml_client.js
@@ -60,8 +60,8 @@ const openCenteredPopup = function(url, width, height) {
// positioning the popup centered relative to the current window
const left = screenX + (outerWidth - width) / 2;
const top = screenY + (outerHeight - height) / 2;
- const features = ('width=' + width + ',height=' + height +
- ',left=' + left + ',top=' + top + ',scrollbars=yes');
+ const features = (`width=${ width },height=${ height
+ },left=${ left },top=${ top },scrollbars=yes`);
newwindow = window.open(url, 'Login', features);
if (newwindow.focus) {
@@ -74,7 +74,7 @@ const openCenteredPopup = function(url, width, height) {
Accounts.saml.initiateLogin = function(options, callback, dimensions) {
// default dimensions that worked well for facebook and google
const popup = openCenteredPopup(
- Meteor.absoluteUrl('_saml/authorize/' + options.provider + '/' + options.credentialToken), (dimensions && dimensions.width) || 650, (dimensions && dimensions.height) || 500);
+ Meteor.absoluteUrl(`_saml/authorize/${ options.provider }/${ options.credentialToken }`), (dimensions && dimensions.width) || 650, (dimensions && dimensions.height) || 500);
const checkPopupOpen = setInterval(function() {
let popupClosed;
@@ -124,6 +124,6 @@ Meteor.logoutWithSaml = function(options/*, callback*/) {
}
// A nasty bounce: 'result' has the SAML LogoutRequest but we need a proper 302 to redirected from the server.
//window.location.replace(Meteor.absoluteUrl('_saml/sloRedirect/' + options.provider + '/?redirect='+result));
- window.location.replace(Meteor.absoluteUrl('_saml/sloRedirect/' + options.provider + '/?redirect=' + encodeURIComponent(result)));
+ window.location.replace(Meteor.absoluteUrl(`_saml/sloRedirect/${ options.provider }/?redirect=${ encodeURIComponent(result) }`));
});
};
diff --git a/packages/meteor-accounts-saml/saml_rocketchat.js b/packages/meteor-accounts-saml/saml_rocketchat.js
index 19132b755a0..31b5aeffa12 100644
--- a/packages/meteor-accounts-saml/saml_rocketchat.js
+++ b/packages/meteor-accounts-saml/saml_rocketchat.js
@@ -10,76 +10,76 @@ RocketChat.settings.addGroup('SAML');
Meteor.methods({
addSamlService(name) {
- RocketChat.settings.add(`SAML_Custom_${name}`, false, {
+ RocketChat.settings.add(`SAML_Custom_${ name }`, false, {
type: 'boolean',
group: 'SAML',
section: name,
i18nLabel: 'Accounts_OAuth_Custom_Enable'
});
- RocketChat.settings.add(`SAML_Custom_${name}_provider`, 'provider-name', {
+ RocketChat.settings.add(`SAML_Custom_${ name }_provider`, 'provider-name', {
type: 'string',
group: 'SAML',
section: name,
i18nLabel: 'SAML_Custom_Provider'
});
- RocketChat.settings.add(`SAML_Custom_${name}_entry_point`, 'https://example.com/simplesaml/saml2/idp/SSOService.php', {
+ RocketChat.settings.add(`SAML_Custom_${ name }_entry_point`, 'https://example.com/simplesaml/saml2/idp/SSOService.php', {
type: 'string',
group: 'SAML',
section: name,
i18nLabel: 'SAML_Custom_Entry_point'
});
- RocketChat.settings.add(`SAML_Custom_${name}_idp_slo_redirect_url`, 'https://example.com/simplesaml/saml2/idp/SingleLogoutService.php', {
+ RocketChat.settings.add(`SAML_Custom_${ name }_idp_slo_redirect_url`, 'https://example.com/simplesaml/saml2/idp/SingleLogoutService.php', {
type: 'string',
group: 'SAML',
section: name,
i18nLabel: 'SAML_Custom_IDP_SLO_Redirect_URL'
});
- RocketChat.settings.add(`SAML_Custom_${name}_issuer`, 'https://your-rocket-chat/_saml/metadata/provider-name', {
+ RocketChat.settings.add(`SAML_Custom_${ name }_issuer`, 'https://your-rocket-chat/_saml/metadata/provider-name', {
type: 'string',
group: 'SAML',
section: name,
i18nLabel: 'SAML_Custom_Issuer'
});
- RocketChat.settings.add(`SAML_Custom_${name}_cert`, '', {
+ RocketChat.settings.add(`SAML_Custom_${ name }_cert`, '', {
type: 'string',
group: 'SAML',
section: name,
i18nLabel: 'SAML_Custom_Cert',
multiline: true
});
- RocketChat.settings.add(`SAML_Custom_${name}_public_cert`, '', {
+ RocketChat.settings.add(`SAML_Custom_${ name }_public_cert`, '', {
type: 'string',
group: 'SAML',
section: name,
multiline: true,
i18nLabel: 'SAML_Custom_Public_Cert'
});
- RocketChat.settings.add(`SAML_Custom_${name}_private_key`, '', {
+ RocketChat.settings.add(`SAML_Custom_${ name }_private_key`, '', {
type: 'string',
group: 'SAML',
section: name,
multiline: true,
i18nLabel: 'SAML_Custom_Private_Key'
});
- RocketChat.settings.add(`SAML_Custom_${name}_button_label_text`, '', {
+ RocketChat.settings.add(`SAML_Custom_${ name }_button_label_text`, '', {
type: 'string',
group: 'SAML',
section: name,
i18nLabel: 'Accounts_OAuth_Custom_Button_Label_Text'
});
- RocketChat.settings.add(`SAML_Custom_${name}_button_label_color`, '#FFFFFF', {
+ RocketChat.settings.add(`SAML_Custom_${ name }_button_label_color`, '#FFFFFF', {
type: 'string',
group: 'SAML',
section: name,
i18nLabel: 'Accounts_OAuth_Custom_Button_Label_Color'
});
- RocketChat.settings.add(`SAML_Custom_${name}_button_color`, '#13679A', {
+ RocketChat.settings.add(`SAML_Custom_${ name }_button_color`, '#13679A', {
type: 'string',
group: 'SAML',
section: name,
i18nLabel: 'Accounts_OAuth_Custom_Button_Color'
});
- RocketChat.settings.add(`SAML_Custom_${name}_generate_username`, false, {
+ RocketChat.settings.add(`SAML_Custom_${ name }_generate_username`, false, {
type: 'boolean',
group: 'SAML',
section: name,
@@ -90,20 +90,20 @@ Meteor.methods({
const getSamlConfigs = function(service) {
return {
- buttonLabelText: RocketChat.settings.get(service.key + '_button_label_text'),
- buttonLabelColor: RocketChat.settings.get(service.key + '_button_label_color'),
- buttonColor: RocketChat.settings.get(service.key + '_button_color'),
+ buttonLabelText: RocketChat.settings.get(`${ service.key }_button_label_text`),
+ buttonLabelColor: RocketChat.settings.get(`${ service.key }_button_label_color`),
+ buttonColor: RocketChat.settings.get(`${ service.key }_button_color`),
clientConfig: {
- provider: RocketChat.settings.get(service.key + '_provider')
+ provider: RocketChat.settings.get(`${ service.key }_provider`)
},
- entryPoint: RocketChat.settings.get(service.key + '_entry_point'),
- idpSLORedirectURL: RocketChat.settings.get(service.key + '_idp_slo_redirect_url'),
- generateUsername: RocketChat.settings.get(service.key + '_generate_username'),
- issuer: RocketChat.settings.get(service.key + '_issuer'),
+ entryPoint: RocketChat.settings.get(`${ service.key }_entry_point`),
+ idpSLORedirectURL: RocketChat.settings.get(`${ service.key }_idp_slo_redirect_url`),
+ generateUsername: RocketChat.settings.get(`${ service.key }_generate_username`),
+ issuer: RocketChat.settings.get(`${ service.key }_issuer`),
secret: {
- privateKey: RocketChat.settings.get(service.key + '_private_key'),
- publicCert: RocketChat.settings.get(service.key + '_public_cert'),
- cert: RocketChat.settings.get(service.key + '_cert')
+ privateKey: RocketChat.settings.get(`${ service.key }_private_key`),
+ publicCert: RocketChat.settings.get(`${ service.key }_public_cert`),
+ cert: RocketChat.settings.get(`${ service.key }_cert`)
}
};
};
diff --git a/packages/meteor-accounts-saml/saml_server.js b/packages/meteor-accounts-saml/saml_server.js
index b56aff3379f..67e32b7b30c 100644
--- a/packages/meteor-accounts-saml/saml_server.js
+++ b/packages/meteor-accounts-saml/saml_server.js
@@ -39,7 +39,7 @@ Meteor.methods({
const providerConfig = getSamlProviderConfig(provider);
if (Accounts.saml.settings.debug) {
- console.log('Logout request from ' + JSON.stringify(providerConfig));
+ console.log(`Logout request from ${ JSON.stringify(providerConfig) }`);
}
// This query should respect upcoming array of SAML logins
const user = Meteor.users.findOne({
@@ -52,7 +52,7 @@ Meteor.methods({
const sessionIndex = user.services.saml.idpSession;
nameID = sessionIndex;
if (Accounts.saml.settings.debug) {
- console.log('NameID for user ' + Meteor.userId() + ' found: ' + JSON.stringify(nameID));
+ console.log(`NameID for user ${ Meteor.userId() } found: ${ JSON.stringify(nameID) }`);
}
const _saml = new SAML(providerConfig);
@@ -76,7 +76,7 @@ Meteor.methods({
const _syncRequestToUrl = Meteor.wrapAsync(_saml.requestToUrl, _saml);
const result = _syncRequestToUrl(request.request, 'logout');
if (Accounts.saml.settings.debug) {
- console.log('SAML Logout Request ' + result);
+ console.log(`SAML Logout Request ${ result }`);
}
@@ -91,7 +91,7 @@ Accounts.registerLoginHandler(function(loginRequest) {
const loginResult = Accounts.saml.retrieveCredential(loginRequest.credentialToken);
if (Accounts.saml.settings.debug) {
- console.log('RESULT :' + JSON.stringify(loginResult));
+ console.log(`RESULT :${ JSON.stringify(loginResult) }`);
}
if (loginResult === undefined) {
@@ -186,7 +186,7 @@ const closePopup = function(res, err) {
});
let content = '
Verified
';
if (err) {
- content = 'Sorry, an annoying error occured
' + err + '
Close Window';
+ content = `Sorry, an annoying error occured
${ err }
Close Window`;
}
res.end(content, 'utf-8');
};
@@ -239,13 +239,13 @@ const middleware = function(req, res, next) {
// Skip everything if there's no service set by the saml middleware
if (!service) {
- throw new Error('Unexpected SAML service ' + samlObject.serviceName);
+ throw new Error(`Unexpected SAML service ${ samlObject.serviceName }`);
}
let _saml;
switch (samlObject.actionName) {
case 'metadata':
_saml = new SAML(service);
- service.callbackUrl = Meteor.absoluteUrl('_saml/validate/' + service.provider);
+ service.callbackUrl = Meteor.absoluteUrl(`_saml/validate/${ service.provider }`);
res.writeHead(200);
res.write(_saml.generateServiceProviderMetadata(service.callbackUrl));
res.end();
@@ -258,14 +258,14 @@ const middleware = function(req, res, next) {
if (!err) {
const logOutUser = function(inResponseTo) {
if (Accounts.saml.settings.debug) {
- console.log('Logging Out user via inResponseTo ' + inResponseTo);
+ console.log(`Logging Out user via inResponseTo ${ inResponseTo }`);
}
const loggedOutUser = Meteor.users.find({
'services.saml.inResponseTo': inResponseTo
}).fetch();
if (loggedOutUser.length === 1) {
if (Accounts.saml.settings.debug) {
- console.log('Found user ' + loggedOutUser[0]._id);
+ console.log(`Found user ${ loggedOutUser[0]._id }`);
}
Meteor.users.update({
_id: loggedOutUser[0]._id
@@ -309,7 +309,7 @@ const middleware = function(req, res, next) {
res.end();
break;
case 'authorize':
- service.callbackUrl = Meteor.absoluteUrl('_saml/validate/' + service.provider);
+ service.callbackUrl = Meteor.absoluteUrl(`_saml/validate/${ service.provider }`);
service.id = samlObject.credentialToken;
_saml = new SAML(service);
_saml.getAuthorizeUrl(req, function(err, url) {
@@ -327,7 +327,7 @@ const middleware = function(req, res, next) {
Accounts.saml.RelayState = req.body.RelayState;
_saml.validateResponse(req.body.SAMLResponse, req.body.RelayState, function(err, profile/*, loggedOut*/) {
if (err) {
- throw new Error('Unable to validate response url: ' + err);
+ throw new Error(`Unable to validate response url: ${ err }`);
}
const credentialToken = profile.inResponseToId || profile.InResponseTo || samlObject.credentialToken;
@@ -337,7 +337,7 @@ const middleware = function(req, res, next) {
Accounts.saml._loginResultForCredentialToken[saml_idp_credentialToken] = {
profile
};
- const url = Meteor.absoluteUrl('home') + '?saml_idp_credentialToken='+saml_idp_credentialToken;
+ const url = `${ Meteor.absoluteUrl('home') }?saml_idp_credentialToken=${ saml_idp_credentialToken }`;
res.writeHead(302, {
'Location': url
});
@@ -351,7 +351,7 @@ const middleware = function(req, res, next) {
});
break;
default:
- throw new Error('Unexpected SAML action ' + samlObject.actionName);
+ throw new Error(`Unexpected SAML action ${ samlObject.actionName }`);
}
} catch (err) {
diff --git a/packages/meteor-accounts-saml/saml_utils.js b/packages/meteor-accounts-saml/saml_utils.js
index 51d17d7afb6..5d8396e88ec 100644
--- a/packages/meteor-accounts-saml/saml_utils.js
+++ b/packages/meteor-accounts-saml/saml_utils.js
@@ -67,7 +67,7 @@ SAML.prototype.signRequest = function(xml) {
};
SAML.prototype.generateAuthorizeRequest = function(req) {
- let id = '_' + this.generateUniqueID();
+ let id = `_${ this.generateUniqueID() }`;
const instant = this.generateInstant();
// Post-auth destination
@@ -83,14 +83,14 @@ SAML.prototype.generateAuthorizeRequest = function(req) {
}
let request =
- '' +
- '' + this.options.issuer + '\n';
+ `` +
+ `${ this.options.issuer }\n`;
if (this.options.identifierFormat) {
- request += '\n';
+ request += `\n`;
}
request +=
@@ -107,29 +107,29 @@ SAML.prototype.generateLogoutRequest = function(options) {
// sessionIndex: sessionIndex
// --- NO SAMLsettings: ' +
- '' + this.options.issuer + '' +
- '' + options.nameID + '' +
+ let request = `${ '` +
+ `${ this.options.issuer }` +
+ `${ options.nameID }` +
'';
- request = '' +
- '' + this.options.issuer + '' +
+ `${ this.options.issuer }` +
'' +
- options.nameID + '' +
- '' + options.sessionIndex + '' +
+ `SPNameQualifier="${ this.options.issuer }" ` +
+ `Format="${ this.options.identifierFormat }">${
+ options.nameID }` +
+ `${ options.sessionIndex }` +
'';
if (Meteor.settings.debug) {
console.log('------- SAML Logout request -----------');
@@ -185,7 +185,7 @@ SAML.prototype.requestToUrl = function(request, operation, callback) {
target += querystring.stringify(samlRequest);
if (Meteor.settings.debug) {
- console.log('requestToUrl: ' + target);
+ console.log(`requestToUrl: ${ target }`);
}
if (operation === 'logout') {
// in case of logout we want to be redirected back to the Meteor app.
@@ -211,8 +211,8 @@ SAML.prototype.getLogoutUrl = function(req, callback) {
SAML.prototype.certToPEM = function(cert) {
cert = cert.match(/.{1,64}/g).join('\n');
- cert = '-----BEGIN CERTIFICATE-----\n' + cert;
- cert = cert + '\n-----END CERTIFICATE-----\n';
+ cert = `-----BEGIN CERTIFICATE-----\n${ cert }`;
+ cert = `${ cert }\n-----END CERTIFICATE-----\n`;
return cert;
};
@@ -250,14 +250,14 @@ SAML.prototype.validateSignature = function(xml, cert) {
};
SAML.prototype.getElement = function(parentElement, elementName) {
- if (parentElement['saml:' + elementName]) {
- return parentElement['saml:' + elementName];
- } else if (parentElement['samlp:' + elementName]) {
- return parentElement['samlp:' + elementName];
- } else if (parentElement['saml2p:' + elementName]) {
- return parentElement['saml2p:' + elementName];
- } else if (parentElement['saml2:' + elementName]) {
- return parentElement['saml2:' + elementName];
+ if (parentElement[`saml:${ elementName }`]) {
+ return parentElement[`saml:${ elementName }`];
+ } else if (parentElement[`samlp:${ elementName }`]) {
+ return parentElement[`samlp:${ elementName }`];
+ } else if (parentElement[`saml2p:${ elementName }`]) {
+ return parentElement[`saml2p:${ elementName }`];
+ } else if (parentElement[`saml2:${ elementName }`]) {
+ return parentElement[`saml2:${ elementName }`];
}
return parentElement[elementName];
};
@@ -283,12 +283,12 @@ SAML.prototype.validateLogoutResponse = function(samlResponse, callback) {
// TBD. Check if this msg corresponds to one we sent
const inResponseTo = response.$.InResponseTo;
if (Meteor.settings.debug) {
- console.log('In Response to: ' + inResponseTo);
+ console.log(`In Response to: ${ inResponseTo }`);
}
const status = self.getElement(response, 'Status');
const statusCode = self.getElement(status[0], 'StatusCode')[0].$.Value;
if (Meteor.settings.debug) {
- console.log('StatusCode: ' + JSON.stringify(statusCode));
+ console.log(`StatusCode: ${ JSON.stringify(statusCode) }`);
}
if (statusCode === 'urn:oasis:names:tc:SAML:2.0:status:Success') {
// In case of a successful logout at IDP we return inResponseTo value.
@@ -311,7 +311,7 @@ SAML.prototype.validateResponse = function(samlResponse, relayState, callback) {
const xml = new Buffer(samlResponse, 'base64').toString('utf8');
// We currently use RelayState to save SAML provider
if (Meteor.settings.debug) {
- console.log('Validating response with relay state: ' + xml);
+ console.log(`Validating response with relay state: ${ xml }`);
}
const parser = new xml2js.Parser({
explicitRoot: true
@@ -372,7 +372,7 @@ SAML.prototype.validateResponse = function(samlResponse, relayState, callback) {
profile.sessionIndex = authnStatement[0].$.SessionIndex;
if (Meteor.settings.debug) {
- console.log('Session Index: ' + profile.sessionIndex);
+ console.log(`Session Index: ${ profile.sessionIndex }`);
}
} else if (Meteor.settings.debug) {
console.log('No Session Index Found');
@@ -412,7 +412,7 @@ SAML.prototype.validateResponse = function(samlResponse, relayState, callback) {
profile.email = profile.nameID;
}
if (Meteor.settings.debug) {
- console.log('NameID: ' + JSON.stringify(profile));
+ console.log(`NameID: ${ JSON.stringify(profile) }`);
}
callback(null, profile, false);
@@ -492,8 +492,8 @@ SAML.prototype.generateServiceProviderMetadata = function(callbackUrl) {
'KeyDescriptor': keyDescriptor,
'SingleLogoutService': {
'@Binding': 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',
- '@Location': Meteor.absoluteUrl() + '_saml/logout/' + this.options.provider + '/',
- '@ResponseLocation': Meteor.absoluteUrl() + '_saml/logout/' + this.options.provider + '/'
+ '@Location': `${ Meteor.absoluteUrl() }_saml/logout/${ this.options.provider }/`,
+ '@ResponseLocation': `${ Meteor.absoluteUrl() }_saml/logout/${ this.options.provider }/`
},
'NameIDFormat': this.options.identifierFormat,
'AssertionConsumerService': {
diff --git a/packages/rocketchat-analytics/client/loadScript.js b/packages/rocketchat-analytics/client/loadScript.js
index a22e8afe317..ee5ff00380b 100644
--- a/packages/rocketchat-analytics/client/loadScript.js
+++ b/packages/rocketchat-analytics/client/loadScript.js
@@ -15,7 +15,7 @@ Template.body.onRendered(() => {
window._paq.push(['trackPageView']);
window._paq.push(['enableLinkTracking']);
(() => {
- window._paq.push(['setTrackerUrl', piwikUrl + 'piwik.php']);
+ window._paq.push(['setTrackerUrl', `${ piwikUrl }piwik.php`]);
window._paq.push(['setSiteId', Number.parseInt(piwikSiteId)]);
const d = document;
const g = d.createElement('script');
@@ -23,7 +23,7 @@ Template.body.onRendered(() => {
g.type = 'text/javascript';
g.async = true;
g.defer = true;
- g.src = piwikUrl + 'piwik.js';
+ g.src = `${ piwikUrl }piwik.js`;
s.parentNode.insertBefore(g, s);
})();
}
diff --git a/packages/rocketchat-analytics/client/trackEvents.js b/packages/rocketchat-analytics/client/trackEvents.js
index c672e8bb73d..5ecaff9b6ac 100644
--- a/packages/rocketchat-analytics/client/trackEvents.js
+++ b/packages/rocketchat-analytics/client/trackEvents.js
@@ -31,44 +31,44 @@ if (!window._paq || window.ga) {
RocketChat.callbacks.add('afterSaveMessage', (message) => {
if ((window._paq || window.ga) && RocketChat.settings.get('Analytics_features_messages')) {
const room = ChatRoom.findOne({ _id: message.rid });
- trackEvent('Message', 'Send', room.name + ' (' + room._id + ')');
+ trackEvent('Message', 'Send', `${ room.name } (${ room._id })`);
}
}, 2000, 'trackEvents');
//Rooms
RocketChat.callbacks.add('afterCreateChannel', (owner, room) => {
if (RocketChat.settings.get('Analytics_features_rooms')) {
- trackEvent('Room', 'Create', room.name + ' (' + room._id + ')');
+ trackEvent('Room', 'Create', `${ room.name } (${ room._id })`);
}
}, RocketChat.callbacks.priority.MEDIUM, 'analytics-after-create-channel');
RocketChat.callbacks.add('roomNameChanged', (room) => {
if (RocketChat.settings.get('Analytics_features_rooms')) {
- trackEvent('Room', 'Changed Name', room.name + ' (' + room._id + ')');
+ trackEvent('Room', 'Changed Name', `${ room.name } (${ room._id })`);
}
}, RocketChat.callbacks.priority.MEDIUM, 'analytics-room-name-changed');
RocketChat.callbacks.add('roomTopicChanged', (room) => {
if (RocketChat.settings.get('Analytics_features_rooms')) {
- trackEvent('Room', 'Changed Topic', room.name + ' (' + room._id + ')');
+ trackEvent('Room', 'Changed Topic', `${ room.name } (${ room._id })`);
}
}, RocketChat.callbacks.priority.MEDIUM, 'analytics-room-topic-changed');
RocketChat.callbacks.add('roomTypeChanged', (room) => {
if (RocketChat.settings.get('Analytics_features_rooms')) {
- trackEvent('Room', 'Changed Room Type', room.name + ' (' + room._id + ')');
+ trackEvent('Room', 'Changed Room Type', `${ room.name } (${ room._id })`);
}
}, RocketChat.callbacks.priority.MEDIUM, 'analytics-room-type-changed');
RocketChat.callbacks.add('archiveRoom', (room) => {
if (RocketChat.settings.get('Analytics_features_rooms')) {
- trackEvent('Room', 'Archived', room.name + ' (' + room._id + ')');
+ trackEvent('Room', 'Archived', `${ room.name } (${ room._id })`);
}
}, RocketChat.callbacks.priority.MEDIUM, 'analytics-archive-room');
RocketChat.callbacks.add('unarchiveRoom', (room) => {
if (RocketChat.settings.get('Analytics_features_rooms')) {
- trackEvent('Room', 'Unarchived', room.name + ' (' + room._id + ')');
+ trackEvent('Room', 'Unarchived', `${ room.name } (${ room._id })`);
}
}, RocketChat.callbacks.priority.MEDIUM, 'analytics-unarchive-room');
diff --git a/packages/rocketchat-api/server/api.js b/packages/rocketchat-api/server/api.js
index 10e5b561999..f1e71eeaa5a 100644
--- a/packages/rocketchat-api/server/api.js
+++ b/packages/rocketchat-api/server/api.js
@@ -2,7 +2,7 @@
class API extends Restivus {
constructor(properties) {
super(properties);
- this.logger = new Logger(`API ${properties.version ? properties.version : 'default'} Logger`, {});
+ this.logger = new Logger(`API ${ properties.version ? properties.version : 'default' } Logger`, {});
this.authMethods = [];
this.helperMethods = new Map();
this.defaultFieldsToExclude = {
@@ -99,12 +99,12 @@ class API extends Restivus {
//Add a try/catch for each much
const originalAction = endpoints[method].action;
endpoints[method].action = function() {
- this.logger.debug(`${this.request.method.toUpperCase()}: ${this.request.url}`);
+ this.logger.debug(`${ this.request.method.toUpperCase() }: ${ this.request.url }`);
let result;
try {
result = originalAction.apply(this);
} catch (e) {
- this.logger.debug(`${method} ${route} threw an error:`, e);
+ this.logger.debug(`${ method } ${ route } threw an error:`, e);
return RocketChat.API.v1.failure(e.message, e.error);
}
diff --git a/packages/rocketchat-api/server/v1/channels.js b/packages/rocketchat-api/server/v1/channels.js
index bb820176ecb..4e7ae8cca47 100644
--- a/packages/rocketchat-api/server/v1/channels.js
+++ b/packages/rocketchat-api/server/v1/channels.js
@@ -7,11 +7,11 @@ function findChannelById({ roomId, checkedArchived = true }) {
const room = RocketChat.models.Rooms.findOneById(roomId, { fields: RocketChat.API.v1.defaultFieldsToExclude });
if (!room || room.t !== 'c') {
- throw new Meteor.Error('error-room-not-found', `No channel found by the id of: ${roomId}`);
+ throw new Meteor.Error('error-room-not-found', `No channel found by the id of: ${ roomId }`);
}
if (checkedArchived && room.archived) {
- throw new Meteor.Error('error-room-archived', `The channel, ${room.name}, is archived`);
+ throw new Meteor.Error('error-room-archived', `The channel, ${ room.name }, is archived`);
}
return room;
@@ -106,11 +106,11 @@ RocketChat.API.v1.addRoute('channels.close', { authRequired: true }, {
const sub = RocketChat.models.Subscriptions.findOneByRoomIdAndUserId(findResult._id, this.userId);
if (!sub) {
- return RocketChat.API.v1.failure(`The user/callee is not in the channel "${findResult.name}.`);
+ return RocketChat.API.v1.failure(`The user/callee is not in the channel "${ findResult.name }.`);
}
if (!sub.open) {
- return RocketChat.API.v1.failure(`The channel, ${findResult.name}, is already closed to the sender`);
+ return RocketChat.API.v1.failure(`The channel, ${ findResult.name }, is already closed to the sender`);
}
Meteor.runAsUser(this.userId, () => {
@@ -185,7 +185,7 @@ RocketChat.API.v1.addRoute('channels.getIntegrations', { authRequired: true }, {
}
let ourQuery = {
- channel: `#${findResult.name}`
+ channel: `#${ findResult.name }`
};
if (includeAllPublicChannels) {
@@ -414,11 +414,11 @@ RocketChat.API.v1.addRoute('channels.open', { authRequired: true }, {
const sub = RocketChat.models.Subscriptions.findOneByRoomIdAndUserId(findResult._id, this.userId);
if (!sub) {
- return RocketChat.API.v1.failure(`The user/callee is not in the channel "${findResult.name}".`);
+ return RocketChat.API.v1.failure(`The user/callee is not in the channel "${ findResult.name }".`);
}
if (sub.open) {
- return RocketChat.API.v1.failure(`The channel, ${findResult.name}, is already open to the sender`);
+ return RocketChat.API.v1.failure(`The channel, ${ findResult.name }, is already open to the sender`);
}
Meteor.runAsUser(this.userId, () => {
@@ -612,7 +612,7 @@ RocketChat.API.v1.addRoute('channels.unarchive', { authRequired: true }, {
const findResult = findChannelById({ roomId: this.bodyParams.roomId, checkedArchived: false });
if (!findResult.archived) {
- return RocketChat.API.v1.failure(`The channel, ${findResult.name}, is not archived`);
+ return RocketChat.API.v1.failure(`The channel, ${ findResult.name }, is not archived`);
}
Meteor.runAsUser(this.userId, () => {
diff --git a/packages/rocketchat-api/server/v1/chat.js b/packages/rocketchat-api/server/v1/chat.js
index 384ee2602ec..a003368c9c1 100644
--- a/packages/rocketchat-api/server/v1/chat.js
+++ b/packages/rocketchat-api/server/v1/chat.js
@@ -10,7 +10,7 @@ RocketChat.API.v1.addRoute('chat.delete', { authRequired: true }, {
const msg = RocketChat.models.Messages.findOneById(this.bodyParams.msgId, { fields: { u: 1, rid: 1 }});
if (!msg) {
- return RocketChat.API.v1.failure(`No message found with the id of "${this.bodyParams.msgId}".`);
+ return RocketChat.API.v1.failure(`No message found with the id of "${ this.bodyParams.msgId }".`);
}
if (this.bodyParams.roomId !== msg.rid) {
@@ -56,7 +56,7 @@ RocketChat.API.v1.addRoute('chat.update', { authRequired: true }, {
//Ensure the message exists
if (!msg) {
- return RocketChat.API.v1.failure(`No message found with the id of "${this.bodyParams.msgId}".`);
+ return RocketChat.API.v1.failure(`No message found with the id of "${ this.bodyParams.msgId }".`);
}
if (this.bodyParams.roomId !== msg.rid) {
diff --git a/packages/rocketchat-api/server/v1/groups.js b/packages/rocketchat-api/server/v1/groups.js
index a976d1bdfa5..0e12ecdd19e 100644
--- a/packages/rocketchat-api/server/v1/groups.js
+++ b/packages/rocketchat-api/server/v1/groups.js
@@ -12,11 +12,11 @@ function findPrivateGroupByIdOrName({ roomId, roomName, userId, checkedArchived
}
if (!roomSub || roomSub.t !== 'p') {
- throw new Meteor.Error('error-room-not-found', `No private group by the id of: ${roomId}`);
+ throw new Meteor.Error('error-room-not-found', `No private group by the id of: ${ roomId }`);
}
if (checkedArchived && roomSub.archived) {
- throw new Meteor.Error('error-room-archived', `The private group, ${roomSub.name}, is archived`);
+ throw new Meteor.Error('error-room-archived', `The private group, ${ roomSub.name }, is archived`);
}
return roomSub;
@@ -68,7 +68,7 @@ RocketChat.API.v1.addRoute('groups.close', { authRequired: true }, {
const findResult = findPrivateGroupByIdOrName({ roomId: this.bodyParams.roomId, userId: this.userId, checkedArchived: false });
if (!findResult.open) {
- return RocketChat.API.v1.failure(`The private group with an id "${this.bodyParams.roomId}" is already closed to the sender`);
+ return RocketChat.API.v1.failure(`The private group with an id "${ this.bodyParams.roomId }" is already closed to the sender`);
}
Meteor.runAsUser(this.userId, () => {
@@ -141,7 +141,7 @@ RocketChat.API.v1.addRoute('groups.getIntegrations', { authRequired: true }, {
includeAllPrivateGroups = this.queryParams.includeAllPrivateGroups === 'true';
}
- const channelsToSearch = [`#${findResult.name}`];
+ const channelsToSearch = [`#${ findResult.name }`];
if (includeAllPrivateGroups) {
channelsToSearch.push('all_private_groups');
}
@@ -320,7 +320,7 @@ RocketChat.API.v1.addRoute('groups.open', { authRequired: true }, {
const findResult = findPrivateGroupByIdOrName({ roomId: this.bodyParams.roomId, userId: this.userId, checkedArchived: false });
if (findResult.open) {
- return RocketChat.API.v1.failure(`The private group, ${this.bodyParams.name}, is already open for the sender`);
+ return RocketChat.API.v1.failure(`The private group, ${ this.bodyParams.name }, is already open for the sender`);
}
Meteor.runAsUser(this.userId, () => {
diff --git a/packages/rocketchat-api/server/v1/helpers/parseJsonQuery.js b/packages/rocketchat-api/server/v1/helpers/parseJsonQuery.js
index 073ebf4e83f..1a07cacfa42 100644
--- a/packages/rocketchat-api/server/v1/helpers/parseJsonQuery.js
+++ b/packages/rocketchat-api/server/v1/helpers/parseJsonQuery.js
@@ -4,8 +4,8 @@ RocketChat.API.v1.helperMethods.set('parseJsonQuery', function _parseJsonQuery()
try {
sort = JSON.parse(this.queryParams.sort);
} catch (e) {
- this.logger.warn(`Invalid sort parameter provided "${this.queryParams.sort}":`, e);
- throw new Meteor.Error('error-invalid-sort', `Invalid sort parameter provided: "${this.queryParams.sort}"`, { helperMethod: 'parseJsonQuery' });
+ this.logger.warn(`Invalid sort parameter provided "${ this.queryParams.sort }":`, e);
+ throw new Meteor.Error('error-invalid-sort', `Invalid sort parameter provided: "${ this.queryParams.sort }"`, { helperMethod: 'parseJsonQuery' });
}
}
@@ -14,8 +14,8 @@ RocketChat.API.v1.helperMethods.set('parseJsonQuery', function _parseJsonQuery()
try {
fields = JSON.parse(this.queryParams.fields);
} catch (e) {
- this.logger.warn(`Invalid fields parameter provided "${this.queryParams.fields}":`, e);
- throw new Meteor.Error('error-invalid-fields', `Invalid fields parameter provided: "${this.queryParams.fields}"`, { helperMethod: 'parseJsonQuery' });
+ this.logger.warn(`Invalid fields parameter provided "${ this.queryParams.fields }":`, e);
+ throw new Meteor.Error('error-invalid-fields', `Invalid fields parameter provided: "${ this.queryParams.fields }"`, { helperMethod: 'parseJsonQuery' });
}
}
@@ -24,8 +24,8 @@ RocketChat.API.v1.helperMethods.set('parseJsonQuery', function _parseJsonQuery()
try {
query = JSON.parse(this.queryParams.query);
} catch (e) {
- this.logger.warn(`Invalid query parameter provided "${this.queryParams.query}":`, e);
- throw new Meteor.Error('error-invalid-query', `Invalid query parameter provided: "${this.queryParams.query}"`, { helperMethod: 'parseJsonQuery' });
+ this.logger.warn(`Invalid query parameter provided "${ this.queryParams.query }":`, e);
+ throw new Meteor.Error('error-invalid-query', `Invalid query parameter provided: "${ this.queryParams.query }"`, { helperMethod: 'parseJsonQuery' });
}
}
diff --git a/packages/rocketchat-api/server/v1/im.js b/packages/rocketchat-api/server/v1/im.js
index ead2beed8eb..f0f2c08c8da 100644
--- a/packages/rocketchat-api/server/v1/im.js
+++ b/packages/rocketchat-api/server/v1/im.js
@@ -6,7 +6,7 @@ function findDirectMessageRoomById(roomId, userId) {
const roomSub = RocketChat.models.Subscriptions.findOneByRoomIdAndUserId(roomId, userId);
if (!roomSub || roomSub.t !== 'd') {
- return RocketChat.API.v1.failure(`No direct message room found by the id of: ${roomId}`);
+ return RocketChat.API.v1.failure(`No direct message room found by the id of: ${ roomId }`);
}
return roomSub;
@@ -22,7 +22,7 @@ RocketChat.API.v1.addRoute(['dm.close', 'im.close'], { authRequired: true }, {
}
if (!findResult.open) {
- return RocketChat.API.v1.failure(`The direct message room, ${this.bodyParams.name}, is already closed to the sender`);
+ return RocketChat.API.v1.failure(`The direct message room, ${ this.bodyParams.name }, is already closed to the sender`);
}
Meteor.runAsUser(this.userId, () => {
@@ -95,7 +95,7 @@ RocketChat.API.v1.addRoute(['dm.messages.others', 'im.messages.others'], { authR
const room = RocketChat.models.Rooms.findOneById(roomId);
if (!room || room.t !== 'd') {
- throw new Meteor.Error('error-room-not-found', `No direct message room found by the id of: ${roomId}`);
+ throw new Meteor.Error('error-room-not-found', `No direct message room found by the id of: ${ roomId }`);
}
const { offset, count } = this.getPaginationItems();
@@ -178,7 +178,7 @@ RocketChat.API.v1.addRoute(['dm.open', 'im.open'], { authRequired: true }, {
}
if (findResult.open) {
- return RocketChat.API.v1.failure(`The direct message room, ${this.bodyParams.name}, is already open for the sender`);
+ return RocketChat.API.v1.failure(`The direct message room, ${ this.bodyParams.name }, is already open for the sender`);
}
Meteor.runAsUser(this.userId, () => {
diff --git a/packages/rocketchat-api/server/v1/users.js b/packages/rocketchat-api/server/v1/users.js
index 6892a54d1f2..b1b002afca3 100644
--- a/packages/rocketchat-api/server/v1/users.js
+++ b/packages/rocketchat-api/server/v1/users.js
@@ -55,7 +55,7 @@ RocketChat.API.v1.addRoute('users.getAvatar', { authRequired: false }, {
get() {
const user = this.getUserFromParams();
- const url = RocketChat.getURL(`/avatar/${user.username}`, { cdn: false, full: true });
+ const url = RocketChat.getURL(`/avatar/${ user.username }`, { cdn: false, full: true });
this.response.setHeader('Location', url);
return {
@@ -95,7 +95,7 @@ RocketChat.API.v1.addRoute('users.info', { authRequired: true }, {
});
if (!result || result.length !== 1) {
- return RocketChat.API.v1.failure(`Failed to get the user data for the userId of "${user._id}".`);
+ return RocketChat.API.v1.failure(`Failed to get the user data for the userId of "${ user._id }".`);
}
return RocketChat.API.v1.success({
diff --git a/packages/rocketchat-assets/server/assets.js b/packages/rocketchat-assets/server/assets.js
index d55848474d1..643ce5d7071 100644
--- a/packages/rocketchat-assets/server/assets.js
+++ b/packages/rocketchat-assets/server/assets.js
@@ -173,7 +173,7 @@ RocketChat.Assets = new (class {
const extension = mime.extension(contentType);
if (assets[asset].constraints.extensions.includes(extension) === false) {
- throw new Meteor.Error(contentType, `Invalid file type: ${contentType}`, {
+ throw new Meteor.Error(contentType, `Invalid file type: ${ contentType }`, {
function: 'RocketChat.Assets.setAsset',
errorTitle: 'error-invalid-file-type'
});
@@ -198,9 +198,9 @@ RocketChat.Assets = new (class {
const ws = RocketChatAssetsInstance.createWriteStream(asset, contentType);
ws.on('end', Meteor.bindEnvironment(function() {
return Meteor.setTimeout(function() {
- const key = `Assets_${asset}`;
+ const key = `Assets_${ asset }`;
const value = {
- url: `assets/${asset}.${extension}`,
+ url: `assets/${ asset }.${ extension }`,
defaultUrl: assets[asset].defaultUrl
};
@@ -220,7 +220,7 @@ RocketChat.Assets = new (class {
}
RocketChatAssetsInstance.deleteFile(asset);
- const key = `Assets_${asset}`;
+ const key = `Assets_${ asset }`;
const value = {
defaultUrl: assets[asset].defaultUrl
};
@@ -262,14 +262,14 @@ RocketChat.Assets = new (class {
const extension = settingValue.url.split('.').pop();
return assetValue.cache = {
- path: `assets/${assetKey}.${extension}`,
+ path: `assets/${ assetKey }.${ extension }`,
cacheable: false,
sourceMapUrl: undefined,
where: 'client',
type: 'asset',
content: file.buffer,
extension,
- url: `/assets/${assetKey}.${extension}?${hash}`,
+ url: `/assets/${ assetKey }.${ extension }?${ hash }`,
size: file.length,
uploadDate: file.uploadDate,
contentType: file.contentType,
@@ -287,7 +287,7 @@ RocketChat.settings.add('Assets_SvgFavicon_Enable', true, {
});
function addAssetToSetting(key, value) {
- return RocketChat.settings.add(`Assets_${key}`, {
+ return RocketChat.settings.add(`Assets_${ key }`, {
defaultUrl: value.defaultUrl
}, {
type: 'asset',
@@ -347,22 +347,22 @@ WebAppHashing.calculateClientHash = function(manifest, includeFilter, runtimeCon
size: value.cache.size,
hash: value.cache.hash
};
- WebAppInternals.staticFiles[`/__cordova/assets/${key}`] = value.cache;
- WebAppInternals.staticFiles[`/__cordova/assets/${key}.${value.cache.extension}`] = value.cache;
+ WebAppInternals.staticFiles[`/__cordova/assets/${ key }`] = value.cache;
+ WebAppInternals.staticFiles[`/__cordova/assets/${ key }.${ value.cache.extension }`] = value.cache;
} else {
const extension = value.defaultUrl.split('.').pop();
cache = {
- path: `assets/${key}.${extension}`,
+ path: `assets/${ key }.${ extension }`,
cacheable: false,
sourceMapUrl: undefined,
where: 'client',
type: 'asset',
- url: `/assets/${key}.${extension}?v3`,
+ url: `/assets/${ key }.${ extension }?v3`,
hash: 'v3'
};
- WebAppInternals.staticFiles[`/__cordova/assets/${key}`] = WebAppInternals.staticFiles[`/__cordova/${value.defaultUrl}`];
- WebAppInternals.staticFiles[`/__cordova/assets/${key}.${extension}`] = WebAppInternals.staticFiles[`/__cordova/${value.defaultUrl}`];
+ WebAppInternals.staticFiles[`/__cordova/assets/${ key }`] = WebAppInternals.staticFiles[`/__cordova/${ value.defaultUrl }`];
+ WebAppInternals.staticFiles[`/__cordova/assets/${ key }.${ extension }`] = WebAppInternals.staticFiles[`/__cordova/${ value.defaultUrl }`];
}
const manifestItem = _.findWhere(manifest, {
@@ -445,7 +445,7 @@ WebApp.connectHandlers.use('/assets/', Meteor.bindEnvironment(function(req, res,
if (!file) {
if (assets[params.asset] && assets[params.asset].defaultUrl) {
- req.url = `/${assets[params.asset].defaultUrl}`;
+ req.url = `/${ assets[params.asset].defaultUrl }`;
WebAppInternals.staticFilesMiddleware(WebAppInternals.staticFiles, req, res, next);
} else {
res.writeHead(404);
diff --git a/packages/rocketchat-autotranslate/client/views/autoTranslateFlexTab.js b/packages/rocketchat-autotranslate/client/views/autoTranslateFlexTab.js
index 5a0b3e73014..7dac9ab423c 100644
--- a/packages/rocketchat-autotranslate/client/views/autoTranslateFlexTab.js
+++ b/packages/rocketchat-autotranslate/client/views/autoTranslateFlexTab.js
@@ -80,7 +80,7 @@ Template.autoTranslateFlexTab.onCreated(function() {
case 'autoTranslate':
return true;
case 'autoTranslateLanguage':
- value = this.$('select[name='+ field +']').val();
+ value = this.$(`select[name=${ field }]`).val();
if (!_.findWhere(this.supportedLanguages.get(), { language: value })) {
toastr.error(t('Invalid_setting_s', value || ''));
return false;
@@ -96,10 +96,10 @@ Template.autoTranslateFlexTab.onCreated(function() {
let value;
switch (field) {
case 'autoTranslate':
- value = this.$('input[name='+field+']').prop('checked') ? '1' : '0';
+ value = this.$(`input[name=${ field }]`).prop('checked') ? '1' : '0';
break;
case 'autoTranslateLanguage':
- value = this.$('select[name='+ field +']').val();
+ value = this.$(`select[name=${ field }]`).val();
break;
}
@@ -111,9 +111,9 @@ Template.autoTranslateFlexTab.onCreated(function() {
const query = { rid: this.data.rid, 'u._id': { $ne: Meteor.userId() } };
if (field === 'autoTranslateLanguage') {
- query.$or = [ { [`translations.${previousLanguage}`]: { $exists: 1 } }, { [`translations.${value}`]: { $exists: 1 } }, { [`attachments.translations.${previousLanguage}`]: { $exists: 1 } }, { [`attachments.translations.${value}`]: { $exists: 1 } } ];
+ query.$or = [ { [`translations.${ previousLanguage }`]: { $exists: 1 } }, { [`translations.${ value }`]: { $exists: 1 } }, { [`attachments.translations.${ previousLanguage }`]: { $exists: 1 } }, { [`attachments.translations.${ value }`]: { $exists: 1 } } ];
} else {
- query.$or = [ { [`translations.${subscription.autoTranslateLanguage}`]: { $exists: 1 } }, { [`attachments.translations.${subscription.autoTranslateLanguage}`]: { $exists: 1 } } ];
+ query.$or = [ { [`translations.${ subscription.autoTranslateLanguage }`]: { $exists: 1 } }, { [`attachments.translations.${ subscription.autoTranslateLanguage }`]: { $exists: 1 } } ];
}
if (field === 'autoTranslate' && value === '0') {
diff --git a/packages/rocketchat-autotranslate/server/autotranslate.js b/packages/rocketchat-autotranslate/server/autotranslate.js
index c61c7544456..c5349120f1f 100644
--- a/packages/rocketchat-autotranslate/server/autotranslate.js
+++ b/packages/rocketchat-autotranslate/server/autotranslate.js
@@ -28,7 +28,7 @@ class AutoTranslate {
}
let count = message.tokens.length;
message.msg = message.msg.replace(/:[+\w\d]+:/g, function(match) {
- const token = `{${count++}}`;
+ const token = `{${ count++ }}`;
message.tokens.push({
token,
text: match
@@ -48,14 +48,14 @@ class AutoTranslate {
const schemes = RocketChat.settings.get('Markdown_SupportSchemesForLink').split(',').join('|');
// Support  and [text](http://link)
- message.msg = message.msg.replace(new RegExp(`(!?\\[)([^\\]]+)(\\]\\((?:${schemes}):\\/\\/[^\\)]+\\))`, 'gm'), function(match, pre, text, post) {
- const pretoken = `{${count++}}`;
+ message.msg = message.msg.replace(new RegExp(`(!?\\[)([^\\]]+)(\\]\\((?:${ schemes }):\\/\\/[^\\)]+\\))`, 'gm'), function(match, pre, text, post) {
+ const pretoken = `{${ count++ }}`;
message.tokens.push({
token: pretoken,
text: pre
});
- const posttoken = `{${count++}}`;
+ const posttoken = `{${ count++ }}`;
message.tokens.push({
token: posttoken,
text: post
@@ -65,14 +65,14 @@ class AutoTranslate {
});
// Support
- message.msg = message.msg.replace(new RegExp(`((?:<|<)(?:${schemes}):\\/\\/[^\\|]+\\|)(.+?)(?=>|>)((?:>|>))`, 'gm'), function(match, pre, text, post) {
- const pretoken = `{${count++}}`;
+ message.msg = message.msg.replace(new RegExp(`((?:<|<)(?:${ schemes }):\\/\\/[^\\|]+\\|)(.+?)(?=>|>)((?:>|>))`, 'gm'), function(match, pre, text, post) {
+ const pretoken = `{${ count++ }}`;
message.tokens.push({
token: pretoken,
text: pre
});
- const posttoken = `{${count++}}`;
+ const posttoken = `{${ count++ }}`;
message.tokens.push({
token: posttoken,
text: post
@@ -99,7 +99,7 @@ class AutoTranslate {
if (message.tokens.hasOwnProperty(tokenIndex)) {
const token = message.tokens[tokenIndex].token;
if (token.indexOf('notranslate') === -1) {
- const newToken = `{${count++}}`;
+ const newToken = `{${ count++ }}`;
message.msg = message.msg.replace(token, newToken);
message.tokens[tokenIndex].token = newToken;
}
@@ -117,8 +117,8 @@ class AutoTranslate {
if (message.mentions && message.mentions.length > 0) {
message.mentions.forEach(mention => {
- message.msg = message.msg.replace(new RegExp(`(@${mention.username})`, 'gm'), match => {
- const token = `{${count++}}`;
+ message.msg = message.msg.replace(new RegExp(`(@${ mention.username })`, 'gm'), match => {
+ const token = `{${ count++ }}`;
message.tokens.push({
token,
text: match
@@ -130,8 +130,8 @@ class AutoTranslate {
if (message.channels && message.channels.length > 0) {
message.channels.forEach(channel => {
- message.msg = message.msg.replace(new RegExp(`(#${channel.name})`, 'gm'), match => {
- const token = `{${count++}}`;
+ message.msg = message.msg.replace(new RegExp(`(#${ channel.name })`, 'gm'), match => {
+ const token = `{${ count++ }}`;
message.tokens.push({
token,
text: match
@@ -171,7 +171,7 @@ class AutoTranslate {
let msgs = targetMessage.msg.split('\n');
msgs = msgs.map(msg => encodeURIComponent(msg));
- const query = `q=${msgs.join('&q=')}`;
+ const query = `q=${ msgs.join('&q=') }`;
const supportedLanguages = this.getSupportedLanguages('en');
targetLanguages.forEach(language => {
@@ -203,7 +203,7 @@ class AutoTranslate {
const attachment = message.attachments[index];
const translations = {};
if (attachment.description || attachment.text) {
- const query = `q=${encodeURIComponent(attachment.description || attachment.text)}`;
+ const query = `q=${ encodeURIComponent(attachment.description || attachment.text) }`;
const supportedLanguages = this.getSupportedLanguages('en');
targetLanguages.forEach(language => {
if (language.indexOf('-') !== -1 && !_.findWhere(supportedLanguages, { language })) {
diff --git a/packages/rocketchat-autotranslate/server/models/Messages.js b/packages/rocketchat-autotranslate/server/models/Messages.js
index f8b1db60f25..5297e722ca5 100644
--- a/packages/rocketchat-autotranslate/server/models/Messages.js
+++ b/packages/rocketchat-autotranslate/server/models/Messages.js
@@ -2,7 +2,7 @@ RocketChat.models.Messages.addTranslations = function(messageId, translations) {
const updateObj = {};
Object.keys(translations).forEach((key) => {
const translation = translations[key];
- updateObj[`translations.${key}`] = translation;
+ updateObj[`translations.${ key }`] = translation;
});
return this.update({ _id: messageId }, { $set: updateObj });
};
@@ -11,7 +11,7 @@ RocketChat.models.Messages.addAttachmentTranslations = function(messageId, attac
const updateObj = {};
Object.keys(translations).forEach((key) => {
const translation = translations[key];
- updateObj[`attachments.${attachmentIndex}.translations.${key}`] = translation;
+ updateObj[`attachments.${ attachmentIndex }.translations.${ key }`] = translation;
});
return this.update({ _id: messageId }, { $set: updateObj });
};
diff --git a/packages/rocketchat-cas/cas_client.js b/packages/rocketchat-cas/cas_client.js
index 9b3468f56df..b8d2cc8b0ae 100644
--- a/packages/rocketchat-cas/cas_client.js
+++ b/packages/rocketchat-cas/cas_client.js
@@ -10,7 +10,7 @@ const openCenteredPopup = function(url, width, height) {
// positioning the popup centered relative to the current window
const left = screenX + (outerWidth - width) / 2;
const top = screenY + (outerHeight - height) / 2;
- const features = ('width=' + width + ',height=' + height + ',left=' + left + ',top=' + top + ',scrollbars=yes');
+ const features = (`width=${ width },height=${ height },left=${ left },top=${ top },scrollbars=yes`);
const newwindow = window.open(url, 'Login', features);
if (newwindow.focus) {
@@ -33,7 +33,7 @@ Meteor.loginWithCas = function(options, callback) {
}
const appUrl = Meteor.absoluteUrl().replace(/\/$/, '') + __meteor_runtime_config__.ROOT_URL_PATH_PREFIX;
- const loginUrl = login_url + '?service=' + appUrl + '/_cas/' + credentialToken;
+ const loginUrl = `${ login_url }?service=${ appUrl }/_cas/${ credentialToken }`;
const popup = openCenteredPopup(
loginUrl,
diff --git a/packages/rocketchat-cas/cas_server.js b/packages/rocketchat-cas/cas_server.js
index a78a280d533..6a8516cd180 100644
--- a/packages/rocketchat-cas/cas_server.js
+++ b/packages/rocketchat-cas/cas_server.js
@@ -29,19 +29,19 @@ const casTicket = function(req, token, callback) {
const baseUrl = RocketChat.settings.get('CAS_base_url');
const cas_version = parseFloat(RocketChat.settings.get('CAS_version'));
const appUrl = Meteor.absoluteUrl().replace(/\/$/, '') + __meteor_runtime_config__.ROOT_URL_PATH_PREFIX;
- logger.debug('Using CAS_base_url: ' + baseUrl);
+ logger.debug(`Using CAS_base_url: ${ baseUrl }`);
const cas = new CAS({
base_url: baseUrl,
version: cas_version,
- service: appUrl + '/_cas/' + token
+ service: `${ appUrl }/_cas/${ token }`
});
cas.validate(ticketId, function(err, status, username, details) {
if (err) {
- logger.error('error when trying to validate: ' + err.message);
+ logger.error(`error when trying to validate: ${ err.message }`);
} else if (status) {
- logger.info('Validated user: ' + username);
+ logger.info(`Validated user: ${ username }`);
const user_info = { username };
// CAS 2.0 attributes handling
@@ -50,7 +50,7 @@ const casTicket = function(req, token, callback) {
}
_casCredentialTokens[token] = user_info;
} else {
- logger.error('Unable to validate ticket: ' + ticketId);
+ logger.error(`Unable to validate ticket: ${ ticketId }`);
}
//logger.debug("Receveied response: " + JSON.stringify(details, null , 4));
@@ -87,7 +87,7 @@ const middleware = function(req, res, next) {
});
} catch (err) {
- logger.error('Unexpected error : ' + err.message);
+ logger.error(`Unexpected error : ${ err.message }`);
closePopup(res);
}
};
@@ -169,21 +169,21 @@ Accounts.registerLoginHandler(function(options) {
// Source is our String to interpolate
if (_.isString(source)) {
_.each(ext_attrs, function(value, ext_name) {
- source = source.replace('%' + ext_name + '%', ext_attrs[ext_name]);
+ source = source.replace(`%${ ext_name }%`, ext_attrs[ext_name]);
});
int_attrs[int_name] = source;
- logger.debug('Sourced internal attribute: ' + int_name + ' = ' + source);
+ logger.debug(`Sourced internal attribute: ${ int_name } = ${ source }`);
}
});
}
// Search existing user by its external service id
- logger.debug('Looking up user by id: ' + result.username);
+ logger.debug(`Looking up user by id: ${ result.username }`);
let user = Meteor.users.findOne({ 'services.cas.external_id': result.username });
if (user) {
- logger.debug('Using existing user for \'' + result.username + '\' with id: ' + user._id);
+ logger.debug(`Using existing user for '${ result.username }' with id: ${ user._id }`);
if (sync_enabled) {
logger.debug('Syncing user attributes');
// Update name
@@ -228,15 +228,15 @@ Accounts.registerLoginHandler(function(options) {
}
// Create the user
- logger.debug('User "' + result.username + '" does not exist yet, creating it');
+ logger.debug(`User "${ result.username }" does not exist yet, creating it`);
const userId = Accounts.insertUserDoc({}, newUser);
// Fetch and use it
user = Meteor.users.findOne(userId);
- logger.debug('Created new user for \'' + result.username + '\' with id: ' + user._id);
+ logger.debug(`Created new user for '${ result.username }' with id: ${ user._id }`);
//logger.debug(JSON.stringify(user, undefined, 4));
- logger.debug('Joining user to attribute channels: ' + int_attrs.rooms);
+ logger.debug(`Joining user to attribute channels: ${ int_attrs.rooms }`);
if (int_attrs.rooms) {
_.each(int_attrs.rooms.split(','), function(room_name) {
if (room_name) {
diff --git a/packages/rocketchat-colors/client.js b/packages/rocketchat-colors/client.js
index 80102c8c18a..6b80ee8ce20 100644
--- a/packages/rocketchat-colors/client.js
+++ b/packages/rocketchat-colors/client.js
@@ -8,7 +8,7 @@ function HexColorPreview(message) {
if (_.trim(message.html) && RocketChat.settings.get('HexColorPreview_Enabled')) {
msg = message.html;
msg = msg.replace(/(?:^|\s|\n)(#[A-Fa-f0-9]{3}([A-Fa-f0-9]{3})?)\b/g, function(match, completeColor) {
- return match.replace(completeColor, '' + (completeColor.toUpperCase()) + '
');
+ return match.replace(completeColor, `${ completeColor.toUpperCase() }
`);
});
message.html = msg;
}
diff --git a/packages/rocketchat-cors/cors.js b/packages/rocketchat-cors/cors.js
index b35d22e1717..9b07501d8d3 100644
--- a/packages/rocketchat-cors/cors.js
+++ b/packages/rocketchat-cors/cors.js
@@ -97,7 +97,7 @@ WebApp.httpServer.addListener('request', function(req, res) {
let host = req.headers['host'] || url.parse(Meteor.absoluteUrl()).hostname;
host = host.replace(/:\d+$/, '');
res.writeHead(302, {
- 'Location': 'https://' + host + req.url
+ 'Location': `https://${ host }${ req.url }`
});
res.end();
return;
diff --git a/packages/rocketchat-custom-oauth/custom_oauth_client.js b/packages/rocketchat-custom-oauth/custom_oauth_client.js
index 6c3ed5084e4..191706d9a8d 100644
--- a/packages/rocketchat-custom-oauth/custom_oauth_client.js
+++ b/packages/rocketchat-custom-oauth/custom_oauth_client.js
@@ -46,7 +46,7 @@ export class CustomOAuth {
}
configureLogin() {
- const loginWithService = 'loginWith' + s.capitalize(this.name);
+ const loginWithService = `loginWith${ s.capitalize(this.name) }`;
Meteor[loginWithService] = (options, callback) => {
// support a callback without options
@@ -78,12 +78,12 @@ export class CustomOAuth {
const credentialToken = Random.secret();
const loginStyle = OAuth._loginStyle(this.name, config, options);
- const loginUrl = this.authorizePath +
- '?client_id=' + config.clientId +
- '&redirect_uri=' + OAuth._redirectUri(this.name, config) +
- '&response_type=code' +
- '&state=' + OAuth._stateParam(loginStyle, credentialToken, options.redirectUrl) +
- '&scope=' + this.scope;
+ const loginUrl = `${ this.authorizePath
+ }?client_id=${ config.clientId
+ }&redirect_uri=${ OAuth._redirectUri(this.name, config)
+ }&response_type=code` +
+ `&state=${ OAuth._stateParam(loginStyle, credentialToken, options.redirectUrl)
+ }&scope=${ this.scope }`;
OAuth.launchLogin({
loginService: this.name,
diff --git a/packages/rocketchat-custom-oauth/custom_oauth_server.js b/packages/rocketchat-custom-oauth/custom_oauth_server.js
index 4a938be3517..8a331d95051 100644
--- a/packages/rocketchat-custom-oauth/custom_oauth_server.js
+++ b/packages/rocketchat-custom-oauth/custom_oauth_server.js
@@ -25,7 +25,7 @@ export class CustomOAuth {
this.userAgent = 'Meteor';
if (Meteor.release) {
- this.userAgent += '/' + Meteor.release;
+ this.userAgent += `/${ Meteor.release }`;
}
Accounts.oauth.registerService(this.name);
@@ -79,7 +79,7 @@ export class CustomOAuth {
let response = undefined;
try {
response = HTTP.post(this.tokenPath, {
- auth: config.clientId + ':' + OAuth.openSecret(config.secret),
+ auth: `${ config.clientId }:${ OAuth.openSecret(config.secret) }`,
headers: {
Accept: 'application/json',
'User-Agent': this.userAgent
@@ -94,12 +94,12 @@ export class CustomOAuth {
}
});
} catch (err) {
- const error = new Error(`Failed to complete OAuth handshake with ${this.name} at ${this.tokenPath}. ${err.message}`);
+ const error = new Error(`Failed to complete OAuth handshake with ${ this.name } at ${ this.tokenPath }. ${ err.message }`);
throw _.extend(error, {response: err.response});
}
if (response.data.error) { //if the http response was a json object with an error attribute
- throw new Error(`Failed to complete OAuth handshake with ${this.name} at ${this.tokenPath}. ${response.data.error}`);
+ throw new Error(`Failed to complete OAuth handshake with ${ this.name } at ${ this.tokenPath }. ${ response.data.error }`);
} else {
return response.data.access_token;
}
@@ -112,7 +112,7 @@ export class CustomOAuth {
};
if (this.tokenSentVia === 'header') {
- headers['Authorization'] = 'Bearer ' + accessToken;
+ headers['Authorization'] = `Bearer ${ accessToken }`;
} else {
params['access_token'] = accessToken;
}
@@ -135,7 +135,7 @@ export class CustomOAuth {
return data;
} catch (err) {
- const error = new Error(`Failed to fetch identity from ${this.name} at ${this.identityPath}. ${err.message}`);
+ const error = new Error(`Failed to fetch identity from ${ this.name } at ${ this.identityPath }. ${ err.message }`);
throw _.extend(error, {response: err.response});
}
}
@@ -229,14 +229,14 @@ export class CustomOAuth {
if (this.usernameField.indexOf('#{') > -1) {
username = this.usernameField.replace(/#{(.+?)}/g, function(match, field) {
if (!data[field]) {
- throw new Meteor.Error('field_not_found', `Username template item "${field}" not found in data`, data);
+ throw new Meteor.Error('field_not_found', `Username template item "${ field }" not found in data`, data);
}
return data[field];
});
} else {
username = data[this.usernameField];
if (!username) {
- throw new Meteor.Error('field_not_found', `Username field "${this.usernameField}" not found in data`, data);
+ throw new Meteor.Error('field_not_found', `Username field "${ this.usernameField }" not found in data`, data);
}
}
@@ -263,10 +263,10 @@ export class CustomOAuth {
}
if (this.mergeUsers !== true) {
- throw new Meteor.Error('CustomOAuth', `User with username ${user.username} already exists`);
+ throw new Meteor.Error('CustomOAuth', `User with username ${ user.username } already exists`);
}
- const serviceIdKey = `services.${serviceName}.id`;
+ const serviceIdKey = `services.${ serviceName }.id`;
const update = {
$set: {
[serviceIdKey]: serviceData.id
diff --git a/packages/rocketchat-custom-sounds/admin/adminSounds.js b/packages/rocketchat-custom-sounds/admin/adminSounds.js
index 7dc22fa0973..63972ce1bfd 100644
--- a/packages/rocketchat-custom-sounds/admin/adminSounds.js
+++ b/packages/rocketchat-custom-sounds/admin/adminSounds.js
@@ -124,7 +124,7 @@ Template.adminSounds.events({
'click .icon-play-circled'(e) {
e.preventDefault();
e.stopPropagation();
- const $audio = $('audio#' + this._id);
+ const $audio = $(`audio#${ this._id }`);
if ($audio && $audio[0] && $audio[0].play) {
$audio[0].play();
}
diff --git a/packages/rocketchat-custom-sounds/client/lib/CustomSounds.js b/packages/rocketchat-custom-sounds/client/lib/CustomSounds.js
index 28c096106cf..a1e54b8e772 100644
--- a/packages/rocketchat-custom-sounds/client/lib/CustomSounds.js
+++ b/packages/rocketchat-custom-sounds/client/lib/CustomSounds.js
@@ -30,11 +30,11 @@ class CustomSounds {
const list = this.list.get();
delete list[sound._id];
this.list.set(list);
- $('#' + sound._id).remove();
+ $(`#${ sound._id }`).remove();
}
update(sound) {
- const audio = $(`#${sound._id}`);
+ const audio = $(`#${ sound._id }`);
if (audio && audio[0]) {
const list = this.list.get();
list[sound._id] = sound;
@@ -48,7 +48,7 @@ class CustomSounds {
getURL(sound) {
const path = (Meteor.isCordova) ? Meteor.absoluteUrl().replace(/\/$/, '') : __meteor_runtime_config__.ROOT_URL_PATH_PREFIX || '';
- return `${path}/custom-sounds/${sound._id}.${sound.extension}?_dc=${sound.random || 0}`;
+ return `${ path }/custom-sounds/${ sound._id }.${ sound.extension }?_dc=${ sound.random || 0 }`;
}
getList() {
diff --git a/packages/rocketchat-custom-sounds/server/methods/deleteCustomSound.js b/packages/rocketchat-custom-sounds/server/methods/deleteCustomSound.js
index 82d01933e02..f02eecab307 100644
--- a/packages/rocketchat-custom-sounds/server/methods/deleteCustomSound.js
+++ b/packages/rocketchat-custom-sounds/server/methods/deleteCustomSound.js
@@ -13,7 +13,7 @@ Meteor.methods({
throw new Meteor.Error('Custom_Sound_Error_Invalid_Sound', 'Invalid sound', { method: 'deleteCustomSound' });
}
- RocketChatFileCustomSoundsInstance.deleteFile(`${sound._id}.${sound.extension}`);
+ RocketChatFileCustomSoundsInstance.deleteFile(`${ sound._id }.${ sound.extension }`);
RocketChat.models.CustomSounds.removeByID(_id);
RocketChat.Notifications.notifyAll('deleteCustomSound', {soundData: sound});
diff --git a/packages/rocketchat-custom-sounds/server/methods/insertOrUpdateSound.js b/packages/rocketchat-custom-sounds/server/methods/insertOrUpdateSound.js
index c0dc2b72009..3f4b4a2a4e0 100644
--- a/packages/rocketchat-custom-sounds/server/methods/insertOrUpdateSound.js
+++ b/packages/rocketchat-custom-sounds/server/methods/insertOrUpdateSound.js
@@ -19,7 +19,7 @@ Meteor.methods({
soundData.name = soundData.name.replace(/:/g, '');
if (nameValidation.test(soundData.name)) {
- throw new Meteor.Error('error-input-is-not-a-valid-field', `${soundData.name} is not a valid name`, { method: 'insertOrUpdateSound', input: soundData.name, field: 'Name' });
+ throw new Meteor.Error('error-input-is-not-a-valid-field', `${ soundData.name } is not a valid name`, { method: 'insertOrUpdateSound', input: soundData.name, field: 'Name' });
}
let matchingResults = [];
@@ -48,7 +48,7 @@ Meteor.methods({
} else {
//update sound
if (soundData.newFile) {
- RocketChatFileCustomSoundsInstance.deleteFile(`${soundData._id}.${soundData.previousExtension}`);
+ RocketChatFileCustomSoundsInstance.deleteFile(`${ soundData._id }.${ soundData.previousExtension }`);
}
if (soundData.name !== soundData.previousName) {
diff --git a/packages/rocketchat-custom-sounds/server/methods/uploadCustomSound.js b/packages/rocketchat-custom-sounds/server/methods/uploadCustomSound.js
index 9dabf715edc..a0c52aaacce 100644
--- a/packages/rocketchat-custom-sounds/server/methods/uploadCustomSound.js
+++ b/packages/rocketchat-custom-sounds/server/methods/uploadCustomSound.js
@@ -8,8 +8,8 @@ Meteor.methods({
const file = new Buffer(binaryContent, 'binary');
const rs = RocketChatFile.bufferToStream(file);
- RocketChatFileCustomSoundsInstance.deleteFile(`${soundData._id}.${soundData.extension}`);
- const ws = RocketChatFileCustomSoundsInstance.createWriteStream(`${soundData._id}.${soundData.extension}`, contentType);
+ RocketChatFileCustomSoundsInstance.deleteFile(`${ soundData._id }.${ soundData.extension }`);
+ const ws = RocketChatFileCustomSoundsInstance.createWriteStream(`${ soundData._id }.${ soundData.extension }`, contentType);
ws.on('end', Meteor.bindEnvironment(() =>
Meteor.setTimeout(() => RocketChat.Notifications.notifyAll('updateCustomSound', {soundData})
, 500)
diff --git a/packages/rocketchat-custom-sounds/server/startup/custom-sounds.js b/packages/rocketchat-custom-sounds/server/startup/custom-sounds.js
index 2cc290603f6..7655a35435b 100644
--- a/packages/rocketchat-custom-sounds/server/startup/custom-sounds.js
+++ b/packages/rocketchat-custom-sounds/server/startup/custom-sounds.js
@@ -9,10 +9,10 @@ Meteor.startup(function() {
const RocketChatStore = RocketChatFile[storeType];
if (RocketChatStore == null) {
- throw new Error(`Invalid RocketChatStore type [${storeType}]`);
+ throw new Error(`Invalid RocketChatStore type [${ storeType }]`);
}
- console.log(`Using ${storeType} for custom sounds storage`.green);
+ console.log(`Using ${ storeType } for custom sounds storage`.green);
let path = '~/uploads';
if (RocketChat.settings.get('CustomSounds_FileSystemPath') != null) {
diff --git a/packages/rocketchat-emoji-custom/client/lib/emojiCustom.js b/packages/rocketchat-emoji-custom/client/lib/emojiCustom.js
index 2927f89f4db..89756e7cf67 100644
--- a/packages/rocketchat-emoji-custom/client/lib/emojiCustom.js
+++ b/packages/rocketchat-emoji-custom/client/lib/emojiCustom.js
@@ -5,7 +5,7 @@ RocketChat.emoji.packages.emojiCustom = {
list: [],
render(html) {
- const regShortNames = new RegExp('