diff --git a/packages/rocketchat-custom-sounds/admin/adminSounds.js b/packages/rocketchat-custom-sounds/admin/adminSounds.js index 15b724d82e9..627eadce9ac 100644 --- a/packages/rocketchat-custom-sounds/admin/adminSounds.js +++ b/packages/rocketchat-custom-sounds/admin/adminSounds.js @@ -33,7 +33,7 @@ Template.adminSounds.helpers({ }); Template.adminSounds.onCreated(function() { - let instance = this; + const instance = this; this.limit = new ReactiveVar(50); this.filter = new ReactiveVar(''); this.ready = new ReactiveVar(false); @@ -61,22 +61,22 @@ Template.adminSounds.onCreated(function() { }); this.autorun(function() { - let limit = (isSetNotNull(() => instance.limit))? instance.limit.get() : 0; - let subscription = instance.subscribe('customSounds', '', limit); + const limit = (isSetNotNull(() => instance.limit))? instance.limit.get() : 0; + const subscription = instance.subscribe('customSounds', '', limit); instance.ready.set(subscription.ready()); }); this.customsounds = function() { - let filter = (isSetNotNull(() => instance.filter))? _.trim(instance.filter.get()) : ''; + const filter = (isSetNotNull(() => instance.filter))? _.trim(instance.filter.get()) : ''; let query = {}; if (filter) { - let filterReg = new RegExp(s.escapeRegExp(filter), 'i'); + const filterReg = new RegExp(s.escapeRegExp(filter), 'i'); query = { name: filterReg }; } - let limit = (isSetNotNull(() => instance.limit))? instance.limit.get() : 0; + const limit = (isSetNotNull(() => instance.limit))? instance.limit.get() : 0; return RocketChat.models.CustomSounds.find(query, { limit: limit, sort: { name: 1 }}).fetch(); }; diff --git a/packages/rocketchat-custom-sounds/admin/soundEdit.js b/packages/rocketchat-custom-sounds/admin/soundEdit.js index 9a7ee93d5fa..53c371306ad 100644 --- a/packages/rocketchat-custom-sounds/admin/soundEdit.js +++ b/packages/rocketchat-custom-sounds/admin/soundEdit.js @@ -25,7 +25,7 @@ Template.soundEdit.events({ }, ['change input[type=file]'](ev) { - let e = (isSetNotNull(() => ev.originalEvent)) ? ev.originalEvent : ev; + const e = (isSetNotNull(() => ev.originalEvent)) ? ev.originalEvent : ev; let files = e.target.files; if (!isSetNotNull(() => e.target.files) || files.length === 0) { if (isSetNotNull(() => e.dataTransfer.files)) { @@ -36,7 +36,7 @@ Template.soundEdit.events({ } //using let x of y here seems to have incompatibility with some phones - for (let file in files) { + for (const file in files) { if (files.hasOwnProperty(file)) { Template.instance().soundFile = files[file]; } @@ -61,7 +61,7 @@ Template.soundEdit.onCreated(function() { }; this.getSoundData = () => { - let soundData = {}; + const soundData = {}; if (isSetNotNull(() => this.sound)) { soundData._id = this.sound._id; soundData.previousName = this.sound.name; @@ -74,9 +74,9 @@ Template.soundEdit.onCreated(function() { }; this.validate = () => { - let soundData = this.getSoundData(); + const soundData = this.getSoundData(); - let errors = []; + const errors = []; if (!soundData.name) { errors.push('Name'); } @@ -87,7 +87,7 @@ Template.soundEdit.onCreated(function() { } } - for (let error of errors) { + for (const error of errors) { toastr.error(TAPi18n.__('error-the-field-is-required', { field: TAPi18n.__(error) })); } @@ -103,7 +103,7 @@ Template.soundEdit.onCreated(function() { this.save = (form) => { if (this.validate()) { - let soundData = this.getSoundData(); + const soundData = this.getSoundData(); if (this.soundFile) { soundData.newFile = true; @@ -119,7 +119,7 @@ Template.soundEdit.onCreated(function() { if (this.soundFile) { toastr.info(TAPi18n.__('Uploading_file')); - let reader = new FileReader(); + const reader = new FileReader(); reader.readAsBinaryString(this.soundFile); reader.onloadend = () => { Meteor.call('uploadCustomSound', reader.result, this.soundFile.type, soundData, (uploadError/*, data*/) => { diff --git a/packages/rocketchat-custom-sounds/admin/soundInfo.js b/packages/rocketchat-custom-sounds/admin/soundInfo.js index f0f28e42892..fd1f45e802e 100644 --- a/packages/rocketchat-custom-sounds/admin/soundInfo.js +++ b/packages/rocketchat-custom-sounds/admin/soundInfo.js @@ -1,7 +1,7 @@ /* globals isSetNotNull */ Template.soundInfo.helpers({ name() { - let sound = Template.instance().sound.get(); + const sound = Template.instance().sound.get(); return sound.name; }, @@ -14,14 +14,14 @@ Template.soundInfo.helpers({ }, soundToEdit() { - let instance = Template.instance(); + const instance = Template.instance(); return { sound: instance.sound.get(), back(name) { instance.editingSound.set(); if (isSetNotNull(() => name)) { - let sound = instance.sound.get(); + const sound = instance.sound.get(); if (isSetNotNull(() => sound.name) && sound.name !== name) { return instance.loadedName.set(name); } @@ -35,9 +35,9 @@ Template.soundInfo.events({ ['click .delete'](e, instance) { e.stopPropagation(); e.preventDefault(); - let sound = instance.sound.get(); + const sound = instance.sound.get(); if (isSetNotNull(() => sound)) { - let _id = sound._id; + const _id = sound._id; swal({ title: t('Are_you_sure'), text: t('Custom_Sound_Delete_Warning'), @@ -88,15 +88,15 @@ Template.soundInfo.onCreated(function() { this.loadedName = new ReactiveVar(); this.autorun(() => { - let data = Template.currentData(); + const data = Template.currentData(); if (isSetNotNull(() => data.clear)) { this.clear = data.clear; } }); this.autorun(() => { - let data = Template.currentData(); - let sound = this.sound.get(); + const data = Template.currentData(); + const sound = this.sound.get(); if (isSetNotNull(() => sound.name)) { this.loadedName.set(sound.name); } else if (isSetNotNull(() => data.name)) { @@ -105,7 +105,7 @@ Template.soundInfo.onCreated(function() { }); this.autorun(() => { - let data = Template.currentData(); + const data = Template.currentData(); this.sound.set(data); }); }); diff --git a/packages/rocketchat-custom-sounds/client/lib/CustomSounds.js b/packages/rocketchat-custom-sounds/client/lib/CustomSounds.js index 540fcbfe6f7..b977cd08f70 100644 --- a/packages/rocketchat-custom-sounds/client/lib/CustomSounds.js +++ b/packages/rocketchat-custom-sounds/client/lib/CustomSounds.js @@ -43,7 +43,7 @@ class CustomSounds { } getURL(sound) { - let path = (Meteor.isCordova) ? Meteor.absoluteUrl().replace(/\/$/, '') : __meteor_runtime_config__.ROOT_URL_PATH_PREFIX || ''; + 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}`; } @@ -57,7 +57,7 @@ RocketChat.CustomSounds = new CustomSounds; Meteor.startup(() => Meteor.call('listCustomSounds', (error, result) => { - for (let sound of result) { + for (const sound of result) { RocketChat.CustomSounds.add(sound); } }) diff --git a/packages/rocketchat-custom-sounds/server/methods/insertOrUpdateSound.js b/packages/rocketchat-custom-sounds/server/methods/insertOrUpdateSound.js index 845bda2cec7..c0dc2b72009 100644 --- a/packages/rocketchat-custom-sounds/server/methods/insertOrUpdateSound.js +++ b/packages/rocketchat-custom-sounds/server/methods/insertOrUpdateSound.js @@ -13,7 +13,7 @@ Meteor.methods({ //allow all characters except colon, whitespace, comma, >, <, &, ", ', /, \, (, ) //more practical than allowing specific sets of characters; also allows foreign languages - let nameValidation = /[\s,:><&"'\/\\\(\)]/; + const nameValidation = /[\s,:><&"'\/\\\(\)]/; //silently strip colon; this allows for uploading :soundname: as soundname soundData.name = soundData.name.replace(/:/g, ''); @@ -36,12 +36,12 @@ Meteor.methods({ if (!soundData._id) { //insert sound - let createSound = { + const createSound = { name: soundData.name, extension: soundData.extension }; - let _id = RocketChat.models.CustomSounds.create(createSound); + const _id = RocketChat.models.CustomSounds.create(createSound); createSound._id = _id; return _id; diff --git a/packages/rocketchat-custom-sounds/server/methods/uploadCustomSound.js b/packages/rocketchat-custom-sounds/server/methods/uploadCustomSound.js index 9929871559a..9dabf715edc 100644 --- a/packages/rocketchat-custom-sounds/server/methods/uploadCustomSound.js +++ b/packages/rocketchat-custom-sounds/server/methods/uploadCustomSound.js @@ -5,11 +5,11 @@ Meteor.methods({ throw new Meteor.Error('not_authorized'); } - let file = new Buffer(binaryContent, 'binary'); + const file = new Buffer(binaryContent, 'binary'); - let rs = RocketChatFile.bufferToStream(file); + const rs = RocketChatFile.bufferToStream(file); RocketChatFileCustomSoundsInstance.deleteFile(`${soundData._id}.${soundData.extension}`); - let ws = RocketChatFileCustomSoundsInstance.createWriteStream(`${soundData._id}.${soundData.extension}`, contentType); + 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/models/CustomSounds.js b/packages/rocketchat-custom-sounds/server/models/CustomSounds.js index 45f742ce5ac..25e7bf27b4b 100644 --- a/packages/rocketchat-custom-sounds/server/models/CustomSounds.js +++ b/packages/rocketchat-custom-sounds/server/models/CustomSounds.js @@ -12,7 +12,7 @@ class CustomSounds extends RocketChat.models._Base { //find findByName(name, options) { - let query = { + const query = { name }; @@ -20,7 +20,7 @@ class CustomSounds extends RocketChat.models._Base { } findByNameExceptID(name, except, options) { - let query = { + const query = { _id: { $nin: [ except ] }, name }; @@ -30,7 +30,7 @@ class CustomSounds extends RocketChat.models._Base { //update setName(_id, name) { - let update = { + const update = { $set: { name } diff --git a/packages/rocketchat-custom-sounds/server/publications/customSounds.js b/packages/rocketchat-custom-sounds/server/publications/customSounds.js index 03032018d73..1ecefc930c7 100644 --- a/packages/rocketchat-custom-sounds/server/publications/customSounds.js +++ b/packages/rocketchat-custom-sounds/server/publications/customSounds.js @@ -3,21 +3,21 @@ Meteor.publish('customSounds', function(filter, limit) { return this.ready(); } - let fields = { + const fields = { name: 1, extension: 1 }; filter = s.trim(filter); - let options = { + const options = { fields, limit, sort: { name: 1 } }; if (filter) { - let filterReg = new RegExp(s.escapeRegExp(filter), 'i'); + const filterReg = new RegExp(s.escapeRegExp(filter), 'i'); return RocketChat.models.CustomSounds.findByName(filterReg, options); } diff --git a/packages/rocketchat-custom-sounds/server/startup/custom-sounds.js b/packages/rocketchat-custom-sounds/server/startup/custom-sounds.js index 0f8c10a5240..e9141956668 100644 --- a/packages/rocketchat-custom-sounds/server/startup/custom-sounds.js +++ b/packages/rocketchat-custom-sounds/server/startup/custom-sounds.js @@ -6,7 +6,7 @@ Meteor.startup(function() { storeType = RocketChat.settings.get('CustomSounds_Storage_Type'); } - let RocketChatStore = RocketChatFile[storeType]; + const RocketChatStore = RocketChatFile[storeType]; if (!isSetNotNull(() => RocketChatStore)) { throw new Error(`Invalid RocketChatStore type [${storeType}]`); @@ -29,7 +29,7 @@ Meteor.startup(function() { self = this; return WebApp.connectHandlers.use('/custom-sounds/', Meteor.bindEnvironment(function(req, res/*, next*/) { - let params = + const params = { sound: decodeURIComponent(req.url.replace(/^\//, '').replace(/\?.*$/, '')) }; if (_.isEmpty(params.sound)) { @@ -39,7 +39,7 @@ Meteor.startup(function() { return; } - let file = RocketChatFileCustomSoundsInstance.getFileWithReadStream(params.sound); + const file = RocketChatFileCustomSoundsInstance.getFileWithReadStream(params.sound); if (!file) { return; } @@ -51,7 +51,7 @@ Meteor.startup(function() { fileUploadDate = file.uploadDate.toUTCString(); } - let reqModifiedHeader = req.headers['if-modified-since']; + const reqModifiedHeader = req.headers['if-modified-since']; if (isSetNotNull(() => reqModifiedHeader)) { if (reqModifiedHeader === fileUploadDate) { res.setHeader('Last-Modified', reqModifiedHeader); diff --git a/packages/rocketchat-push-notifications/client/views/pushNotificationsFlexTab.js b/packages/rocketchat-push-notifications/client/views/pushNotificationsFlexTab.js index 2b4f7c0403b..e4b5c94d2d4 100644 --- a/packages/rocketchat-push-notifications/client/views/pushNotificationsFlexTab.js +++ b/packages/rocketchat-push-notifications/client/views/pushNotificationsFlexTab.js @@ -231,14 +231,14 @@ Template.pushNotificationsFlexTab.events({ e.preventDefault(); let audio = $(e.currentTarget).data('play'); if (audio && audio !== 'none') { - let $audio = $('audio#' + audio); + const $audio = $('audio#' + audio); if ($audio && $audio[0] && $audio[0].play) { $audio[0].play(); } } else { audio = Meteor.user() && Meteor.user().settings && Meteor.user().settings.preferences && Meteor.user().settings.preferences.newMessageNotification || 'chime'; if (audio && audio !== 'none') { - let $audio = $('audio#' + audio); + const $audio = $('audio#' + audio); if ($audio && $audio[0] && $audio[0].play) { $audio[0].play(); } @@ -248,9 +248,9 @@ Template.pushNotificationsFlexTab.events({ 'change select[name=audioNotification]'(e) { e.preventDefault(); - let audio = $(e.currentTarget).val(); + const audio = $(e.currentTarget).val(); if (audio && audio !== 'none') { - let $audio = $('audio#' + audio); + const $audio = $('audio#' + audio); if ($audio && $audio[0] && $audio[0].play) { $audio[0].play(); } diff --git a/server/publications/subscription.js b/server/publications/subscription.js index c7955bd7fbe..1018e7d1e76 100644 --- a/server/publications/subscription.js +++ b/server/publications/subscription.js @@ -12,7 +12,7 @@ const fields = { roles: 1, unread: 1, archived: 1, - audioNotification: 1 + audioNotification: 1, desktopNotifications: 1, desktopNotificationDuration: 1, mobilePushNotifications: 1,