Add ESLint rule `object-shorthand` (#6457)

* ESLint add rule `object-shorthand`

* ESLint rocketchat-livechat/assets/rocket-livechat.js

* Add ecmascript package to all packages

* Use ecmascript package for server and client on saml package

* Fix compilation
pull/6456/head^2
Rodrigo Nascimento 9 years ago committed by GitHub
parent e8074d22b6
commit 7b1e076cbc
  1. 3
      .eslintrc
  2. 2
      client/methods/hideRoom.js
  3. 2
      client/methods/leaveRoom.js
  4. 2
      client/methods/openRoom.js
  5. 2
      client/methods/setUserActiveStatus.js
  6. 4
      client/methods/toggleFavorite.js
  7. 4
      client/notifications/notification.js
  8. 2
      client/routes/router.js
  9. 2
      client/startup/startup.js
  10. 4
      packages/meteor-accounts-saml/saml_client.js
  11. 4
      packages/meteor-accounts-saml/saml_rocketchat.js
  12. 10
      packages/meteor-accounts-saml/saml_server.js
  13. 8
      packages/meteor-accounts-saml/saml_utils.js
  14. 4
      packages/rocketchat-action-links/both/lib/actionLinks.js
  15. 2
      packages/rocketchat-api/server/api.js
  16. 2
      packages/rocketchat-api/server/default/info.js
  17. 2
      packages/rocketchat-api/server/default/metrics.js
  18. 58
      packages/rocketchat-api/server/v1/channels.js
  19. 6
      packages/rocketchat-api/server/v1/chat.js
  20. 48
      packages/rocketchat-api/server/v1/groups.js
  21. 14
      packages/rocketchat-api/server/v1/im.js
  22. 12
      packages/rocketchat-api/server/v1/integrations.js
  23. 4
      packages/rocketchat-api/server/v1/misc.js
  24. 18
      packages/rocketchat-api/server/v1/users.js
  25. 4
      packages/rocketchat-assets/server/assets.js
  26. 2
      packages/rocketchat-authorization/client/startup.js
  27. 4
      packages/rocketchat-authorization/client/views/permissionsRole.js
  28. 4
      packages/rocketchat-authorization/server/methods/addUserToRole.js
  29. 6
      packages/rocketchat-authorization/server/methods/removeUserFromRole.js
  30. 2
      packages/rocketchat-authorization/server/models/Base.js
  31. 2
      packages/rocketchat-authorization/server/models/Permissions.js
  32. 2
      packages/rocketchat-authorization/server/publications/usersInRole.js
  33. 2
      packages/rocketchat-autotranslate/client/lib/autotranslate.js
  34. 14
      packages/rocketchat-autotranslate/server/autotranslate.js
  35. 2
      packages/rocketchat-autotranslate/server/methods/saveSettings.js
  36. 10
      packages/rocketchat-autotranslate/server/models/Subscriptions.js
  37. 4
      packages/rocketchat-cas/cas_client.js
  38. 2
      packages/rocketchat-cas/cas_server.js
  39. 4
      packages/rocketchat-crowd/client/loginHelper.js
  40. 6
      packages/rocketchat-crowd/server/crowd.js
  41. 10
      packages/rocketchat-crowd/server/settings.js
  42. 8
      packages/rocketchat-custom-oauth/custom_oauth_client.js
  43. 8
      packages/rocketchat-custom-oauth/custom_oauth_server.js
  44. 2
      packages/rocketchat-custom-sounds/admin/adminSounds.js
  45. 2
      packages/rocketchat-emoji-custom/admin/adminEmoji.js
  46. 2
      packages/rocketchat-emoji-custom/client/lib/emojiCustom.js
  47. 2
      packages/rocketchat-emoji/emojiPicker.js
  48. 4
      packages/rocketchat-emoji/lib/EmojiPicker.js
  49. 2
      packages/rocketchat-file-upload/globalFileRestrictions.js
  50. 6
      packages/rocketchat-file-upload/lib/FileUploadBase.js
  51. 4
      packages/rocketchat-file-upload/server/config/configFileUploadAmazonS3.js
  52. 2
      packages/rocketchat-file-upload/server/config/configFileUploadFileSystem.js
  53. 8
      packages/rocketchat-github-enterprise/startup.js
  54. 8
      packages/rocketchat-gitlab/startup.js
  55. 18
      packages/rocketchat-iframe-login/iframe_client.js
  56. 2
      packages/rocketchat-integrations/client/views/integrationsIncoming.js
  57. 2
      packages/rocketchat-integrations/client/views/integrationsOutgoing.js
  58. 2
      packages/rocketchat-integrations/server/processWebhookMessage.js
  59. 4
      packages/rocketchat-ldap/client/loginHelper.js
  60. 6
      packages/rocketchat-ldap/server/ldap.js
  61. 4
      packages/rocketchat-ldap/server/loginHandler.js
  62. 28
      packages/rocketchat-ldap/server/settings.js
  63. 4
      packages/rocketchat-ldap/server/sync.js
  64. 2
      packages/rocketchat-ldap/server/syncUsers.js
  65. 2
      packages/rocketchat-ldap/server/testConnection.js
  66. 2
      packages/rocketchat-lib/server/functions/createRoom.js
  67. 4
      packages/rocketchat-lib/server/functions/getFullUserData.js
  68. 4
      packages/rocketchat-lib/server/functions/saveUser.js
  69. 2
      packages/rocketchat-lib/server/functions/setEmail.js
  70. 2
      packages/rocketchat-lib/server/functions/updateMessage.js
  71. 2
      packages/rocketchat-lib/server/lib/PushNotification.js
  72. 2
      packages/rocketchat-lib/server/lib/sendNotificationsOnMessage.js
  73. 2
      packages/rocketchat-lib/server/lib/validateEmailDomain.js
  74. 2
      packages/rocketchat-lib/server/methods/addUserToRoom.js
  75. 2
      packages/rocketchat-lib/server/methods/deleteUserOwnAccount.js
  76. 2
      packages/rocketchat-lib/server/methods/saveSetting.js
  77. 4
      packages/rocketchat-lib/server/methods/setEmail.js
  78. 16
      packages/rocketchat-lib/server/models/_BaseCache.js
  79. 8
      packages/rocketchat-lib/server/models/_BaseDb.js
  80. 2
      packages/rocketchat-lib/server/oauth/google.js
  81. 4
      packages/rocketchat-lib/server/oauth/oauth.js
  82. 4
      packages/rocketchat-livechat/app/client/lib/CustomFields.js
  83. 8
      packages/rocketchat-livechat/app/client/lib/commands.js
  84. 14
      packages/rocketchat-livechat/app/client/lib/hooks.js
  85. 10
      packages/rocketchat-livechat/app/client/lib/triggers.js
  86. 14
      packages/rocketchat-livechat/app/client/views/messages.js
  87. 4
      packages/rocketchat-livechat/app/client/views/survey.js
  88. 4
      packages/rocketchat-livechat/client/views/app/livechatCustomFieldForm.js
  89. 2
      packages/rocketchat-livechat/client/views/app/tabbar/visitorInfo.js
  90. 2
      packages/rocketchat-livechat/imports/server/rest/departments.js
  91. 10
      packages/rocketchat-livechat/server/lib/Livechat.js
  92. 4
      packages/rocketchat-livechat/server/lib/QueueMethods.js
  93. 4
      packages/rocketchat-livechat/server/methods/closeByVisitor.js
  94. 6
      packages/rocketchat-livechat/server/methods/closeRoom.js
  95. 12
      packages/rocketchat-livechat/server/methods/registerGuest.js
  96. 2
      packages/rocketchat-livechat/server/methods/returnAsInquiry.js
  97. 2
      packages/rocketchat-livechat/server/methods/saveInfo.js
  98. 4
      packages/rocketchat-livechat/server/methods/sendMessageLivechat.js
  99. 6
      packages/rocketchat-livechat/server/methods/setDepartmentForVisitor.js
  100. 12
      packages/rocketchat-livechat/server/models/LivechatCustomField.js
  101. Some files were not shown because too many files have changed in this diff Show More

@ -78,7 +78,8 @@
"linebreak-style": [2, "unix"],
"quotes": [2, "single"],
"semi": [2, "always"],
"prefer-const": 2
"prefer-const": 2,
"object-shorthand": 2
},
"globals": {
"_" : false,

@ -5,7 +5,7 @@ Meteor.methods({
}
ChatSubscription.update({
rid: rid,
rid,
'u._id': Meteor.userId()
}, {
$set: {

@ -5,7 +5,7 @@ Meteor.methods({
}
ChatSubscription.remove({
rid: rid,
rid,
'u._id': Meteor.userId()
});

@ -5,7 +5,7 @@ Meteor.methods({
}
ChatSubscription.update({
rid: rid,
rid,
'u._id': Meteor.userId()
}, {
$set: {

@ -1,6 +1,6 @@
Meteor.methods({
setUserActiveStatus(userId, active) {
Meteor.users.update(userId, { $set: { active: active } });
Meteor.users.update(userId, { $set: { active } });
return true;
}
});

@ -5,11 +5,11 @@ Meteor.methods({
}
ChatSubscription.update({
rid: rid,
rid,
'u._id': Meteor.userId()
}, {
$set: {
f: f
f
}
});
}

@ -19,9 +19,9 @@ Meteor.startup(function() {
const messageIsInOpenedRoom = openedRoomId === notification.payload.rid;
fireGlobalEvent('notification', {
notification: notification,
notification,
fromOpenedRoom: messageIsInOpenedRoom,
hasFocus: hasFocus
hasFocus
});
if (RocketChat.Layout.isEmbedded()) {

@ -60,7 +60,7 @@ FlowRouter.route('/home', {
saml: true,
credentialToken: queryParams.saml_idp_credentialToken
}],
userCallback: function() { BlazeLayout.render('main', {center: 'home'}); }
userCallback() { BlazeLayout.render('main', {center: 'home'}); }
});
} else {
BlazeLayout.render('main', {center: 'home'});

@ -69,7 +69,7 @@ Meteor.startup(function() {
language = language.toLowerCase();
if (language !== 'en') {
Meteor.call('loadLocale', language, (err, localeFn) => {
Function(localeFn).call({moment: moment});
Function(localeFn).call({moment});
moment.locale(language);
});
}

@ -21,7 +21,7 @@ Meteor.logout = function() {
const provider = samlService.clientConfig && samlService.clientConfig.provider;
if (provider) {
if (samlService.idpSLORedirectURL) {
return Meteor.logoutWithSaml({ provider: provider });
return Meteor.logoutWithSaml({ provider });
}
}
}
@ -108,7 +108,7 @@ Meteor.loginWithSaml = function(options, callback) {
Accounts.callLoginMethod({
methodArguments: [{
saml: true,
credentialToken: credentialToken
credentialToken
}],
userCallback: callback
});

@ -136,8 +136,8 @@ const configureSamlService = function(samlConfigs) {
idpSLORedirectURL: samlConfigs.idpSLORedirectURL,
issuer: samlConfigs.issuer,
cert: samlConfigs.secret.cert,
privateCert: privateCert,
privateKey: privateKey
privateCert,
privateKey
};
};

@ -31,7 +31,7 @@ function getSamlProviderConfig(provider) {
}
Meteor.methods({
samlLogout: function(provider) {
samlLogout(provider) {
// Make sure the user is logged in before initiate SAML SLO
if (!Meteor.userId()) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'samlLogout' });
@ -58,8 +58,8 @@ Meteor.methods({
const _saml = new SAML(providerConfig);
const request = _saml.generateLogoutRequest({
nameID: nameID,
sessionIndex: sessionIndex
nameID,
sessionIndex
});
// request.request: actual XML SAML Request
@ -335,7 +335,7 @@ const middleware = function(req, res, next) {
// No credentialToken in IdP-initiated SSO
const saml_idp_credentialToken = Random.id();
Accounts.saml._loginResultForCredentialToken[saml_idp_credentialToken] = {
profile: profile
profile
};
const url = Meteor.absoluteUrl('home') + '?saml_idp_credentialToken='+saml_idp_credentialToken;
res.writeHead(302, {
@ -344,7 +344,7 @@ const middleware = function(req, res, next) {
res.end();
} else {
Accounts.saml._loginResultForCredentialToken[credentialToken] = {
profile: profile
profile
};
closePopup(res);
}

@ -136,8 +136,8 @@ SAML.prototype.generateLogoutRequest = function(options) {
console.log(request);
}
return {
request: request,
id: id
request,
id
};
};
@ -236,10 +236,10 @@ SAML.prototype.validateSignature = function(xml, cert) {
const sig = new xmlCrypto.SignedXml();
sig.keyInfoProvider = {
getKeyInfo: function(/*key*/) {
getKeyInfo(/*key*/) {
return '<X509Data></X509Data>';
},
getKey: function(/*keyInfo*/) {
getKey(/*keyInfo*/) {
return self.certToPEM(cert);
}
};

@ -1,10 +1,10 @@
//Action Links namespace creation.
RocketChat.actionLinks = {
actions: {},
register: function(name, funct) {
register(name, funct) {
RocketChat.actionLinks.actions[name] = funct;
},
getMessage: function(name, messageId) {
getMessage(name, messageId) {
if (!Meteor.userId()) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', { function: 'actionLinks.getMessage' });
}

@ -131,7 +131,7 @@ const getUserAuth = function _getUserAuth() {
const invalidResults = [undefined, null, false];
return {
token: 'services.resume.loginTokens.hashedToken',
user: function() {
user() {
if (this.bodyParams && this.bodyParams.payload) {
this.bodyParams = JSON.parse(this.bodyParams.payload);
}

@ -1,5 +1,5 @@
RocketChat.API.default.addRoute('info', { authRequired: false }, {
get: function() {
get() {
const user = this.getLoggedInUser();
if (user && RocketChat.authz.hasRole(user._id, 'admin')) {

@ -1,5 +1,5 @@
RocketChat.API.default.addRoute('metrics', { authRequired: false }, {
get: function() {
get() {
return {
headers: { 'Content-Type': 'text/plain' },
body: RocketChat.promclient.register.metrics()

@ -18,7 +18,7 @@ function findChannelById({ roomId, checkedArchived = true }) {
}
RocketChat.API.v1.addRoute('channels.addAll', { authRequired: true }, {
post: function() {
post() {
const findResult = findChannelById({ roomId: this.bodyParams.roomId });
Meteor.runAsUser(this.userId, () => {
@ -32,7 +32,7 @@ RocketChat.API.v1.addRoute('channels.addAll', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('channels.addModerator', { authRequired: true }, {
post: function() {
post() {
const findResult = findChannelById({ roomId: this.bodyParams.roomId });
const user = this.getUserFromParams();
@ -46,7 +46,7 @@ RocketChat.API.v1.addRoute('channels.addModerator', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('channels.addOwner', { authRequired: true }, {
post: function() {
post() {
const findResult = findChannelById({ roomId: this.bodyParams.roomId });
const user = this.getUserFromParams();
@ -60,7 +60,7 @@ RocketChat.API.v1.addRoute('channels.addOwner', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('channels.archive', { authRequired: true }, {
post: function() {
post() {
const findResult = findChannelById({ roomId: this.bodyParams.roomId });
Meteor.runAsUser(this.userId, () => {
@ -72,7 +72,7 @@ RocketChat.API.v1.addRoute('channels.archive', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('channels.cleanHistory', { authRequired: true }, {
post: function() {
post() {
const findResult = findChannelById({ roomId: this.bodyParams.roomId });
if (!this.bodyParams.latest) {
@ -100,7 +100,7 @@ RocketChat.API.v1.addRoute('channels.cleanHistory', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('channels.close', { authRequired: true }, {
post: function() {
post() {
const findResult = findChannelById({ roomId: this.bodyParams.roomId, checkedArchived: false });
const sub = RocketChat.models.Subscriptions.findOneByRoomIdAndUserId(findResult._id, this.userId);
@ -122,7 +122,7 @@ RocketChat.API.v1.addRoute('channels.close', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('channels.create', { authRequired: true }, {
post: function() {
post() {
if (!RocketChat.authz.hasPermission(this.userId, 'create-p')) {
return RocketChat.API.v1.unauthorized();
}
@ -156,7 +156,7 @@ RocketChat.API.v1.addRoute('channels.create', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('channels.delete', { authRequired: true }, {
post: function() {
post() {
const findResult = findChannelById({ roomId: this.bodyParams.roomId, checkedArchived: false });
//The find method returns either with the group or the failur
@ -172,7 +172,7 @@ RocketChat.API.v1.addRoute('channels.delete', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('channels.getIntegrations', { authRequired: true }, {
get: function() {
get() {
if (!RocketChat.authz.hasPermission(this.userId, 'manage-integrations')) {
return RocketChat.API.v1.unauthorized();
}
@ -216,7 +216,7 @@ RocketChat.API.v1.addRoute('channels.getIntegrations', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('channels.history', { authRequired: true }, {
get: function() {
get() {
const findResult = findChannelById({ roomId: this.queryParams.roomId, checkedArchived: false });
let latestDate = new Date();
@ -256,7 +256,7 @@ RocketChat.API.v1.addRoute('channels.history', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('channels.info', { authRequired: true }, {
get: function() {
get() {
const findResult = findChannelById({ roomId: this.queryParams.roomId, checkedArchived: false });
return RocketChat.API.v1.success({
@ -266,7 +266,7 @@ RocketChat.API.v1.addRoute('channels.info', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('channels.invite', { authRequired: true }, {
post: function() {
post() {
const findResult = findChannelById({ roomId: this.bodyParams.roomId });
const user = this.getUserFromParams();
@ -282,7 +282,7 @@ RocketChat.API.v1.addRoute('channels.invite', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('channels.join', { authRequired: true }, {
post: function() {
post() {
const findResult = findChannelById({ roomId: this.bodyParams.roomId });
Meteor.runAsUser(this.userId, () => {
@ -296,7 +296,7 @@ RocketChat.API.v1.addRoute('channels.join', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('channels.kick', { authRequired: true }, {
post: function() {
post() {
const findResult = findChannelById({ roomId: this.bodyParams.roomId });
const user = this.getUserFromParams();
@ -312,7 +312,7 @@ RocketChat.API.v1.addRoute('channels.kick', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('channels.leave', { authRequired: true }, {
post: function() {
post() {
const findResult = findChannelById({ roomId: this.bodyParams.roomId });
Meteor.runAsUser(this.userId, () => {
@ -328,7 +328,7 @@ RocketChat.API.v1.addRoute('channels.leave', { authRequired: true }, {
RocketChat.API.v1.addRoute('channels.list', { authRequired: true }, {
get: {
//This is like this only to provide an example of how we routes can be defined :X
action: function() {
action() {
const { offset, count } = this.getPaginationItems();
const { sort, fields, query } = this.parseJsonQuery();
@ -352,7 +352,7 @@ RocketChat.API.v1.addRoute('channels.list', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('channels.list.joined', { authRequired: true }, {
get: function() {
get() {
const { offset, count } = this.getPaginationItems();
const { sort, fields } = this.parseJsonQuery();
let rooms = _.pluck(RocketChat.models.Subscriptions.findByTypeAndUserId('c', this.userId).fetch(), '_room');
@ -375,7 +375,7 @@ RocketChat.API.v1.addRoute('channels.list.joined', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('channels.online', { authRequired: true }, {
get: function() {
get() {
const { query } = this.parseJsonQuery();
const ourQuery = Object.assign({}, query, { t: 'c' });
@ -408,7 +408,7 @@ RocketChat.API.v1.addRoute('channels.online', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('channels.open', { authRequired: true }, {
post: function() {
post() {
const findResult = findChannelById({ roomId: this.bodyParams.roomId, checkedArchived: false });
const sub = RocketChat.models.Subscriptions.findOneByRoomIdAndUserId(findResult._id, this.userId);
@ -430,7 +430,7 @@ RocketChat.API.v1.addRoute('channels.open', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('channels.removeModerator', { authRequired: true }, {
post: function() {
post() {
const findResult = findChannelById({ roomId: this.bodyParams.roomId });
const user = this.getUserFromParams();
@ -444,7 +444,7 @@ RocketChat.API.v1.addRoute('channels.removeModerator', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('channels.removeOwner', { authRequired: true }, {
post: function() {
post() {
const findResult = findChannelById({ roomId: this.bodyParams.roomId });
const user = this.getUserFromParams();
@ -458,7 +458,7 @@ RocketChat.API.v1.addRoute('channels.removeOwner', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('channels.rename', { authRequired: true }, {
post: function() {
post() {
if (!this.bodyParams.name || !this.bodyParams.name.trim()) {
return RocketChat.API.v1.failure('The bodyParam "name" is required');
}
@ -480,7 +480,7 @@ RocketChat.API.v1.addRoute('channels.rename', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('channels.setDescription', { authRequired: true }, {
post: function() {
post() {
if (!this.bodyParams.description || !this.bodyParams.description.trim()) {
return RocketChat.API.v1.failure('The bodyParam "description" is required');
}
@ -502,7 +502,7 @@ RocketChat.API.v1.addRoute('channels.setDescription', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('channels.setJoinCode', { authRequired: true }, {
post: function() {
post() {
if (!this.bodyParams.joinCode || !this.bodyParams.joinCode.trim()) {
return RocketChat.API.v1.failure('The bodyParam "joinCode" is required');
}
@ -520,7 +520,7 @@ RocketChat.API.v1.addRoute('channels.setJoinCode', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('channels.setPurpose', { authRequired: true }, {
post: function() {
post() {
if (!this.bodyParams.purpose || !this.bodyParams.purpose.trim()) {
return RocketChat.API.v1.failure('The bodyParam "purpose" is required');
}
@ -542,7 +542,7 @@ RocketChat.API.v1.addRoute('channels.setPurpose', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('channels.setReadOnly', { authRequired: true }, {
post: function() {
post() {
if (typeof this.bodyParams.readOnly === 'undefined') {
return RocketChat.API.v1.failure('The bodyParam "readOnly" is required');
}
@ -564,7 +564,7 @@ RocketChat.API.v1.addRoute('channels.setReadOnly', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('channels.setTopic', { authRequired: true }, {
post: function() {
post() {
if (!this.bodyParams.topic || !this.bodyParams.topic.trim()) {
return RocketChat.API.v1.failure('The bodyParam "topic" is required');
}
@ -586,7 +586,7 @@ RocketChat.API.v1.addRoute('channels.setTopic', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('channels.setType', { authRequired: true }, {
post: function() {
post() {
if (!this.bodyParams.type || !this.bodyParams.type.trim()) {
return RocketChat.API.v1.failure('The bodyParam "type" is required');
}
@ -608,7 +608,7 @@ RocketChat.API.v1.addRoute('channels.setType', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('channels.unarchive', { authRequired: true }, {
post: function() {
post() {
const findResult = findChannelById({ roomId: this.bodyParams.roomId, checkedArchived: false });
if (!findResult.archived) {

@ -1,6 +1,6 @@
/* global processWebhookMessage */
RocketChat.API.v1.addRoute('chat.delete', { authRequired: true }, {
post: function() {
post() {
check(this.bodyParams, Match.ObjectIncluding({
msgId: String,
roomId: String,
@ -29,7 +29,7 @@ RocketChat.API.v1.addRoute('chat.delete', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('chat.postMessage', { authRequired: true }, {
post: function() {
post() {
const messageReturn = processWebhookMessage(this.bodyParams, this.user)[0];
if (!messageReturn) {
@ -45,7 +45,7 @@ RocketChat.API.v1.addRoute('chat.postMessage', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('chat.update', { authRequired: true }, {
post: function() {
post() {
check(this.bodyParams, Match.ObjectIncluding({
roomId: String,
msgId: String,

@ -23,7 +23,7 @@ function findPrivateGroupByIdOrName({ roomId, roomName, userId, checkedArchived
}
RocketChat.API.v1.addRoute('groups.addModerator', { authRequired: true }, {
post: function() {
post() {
const findResult = findPrivateGroupByIdOrName({ roomId: this.bodyParams.roomId, userId: this.userId });
const user = this.getUserFromParams();
@ -37,7 +37,7 @@ RocketChat.API.v1.addRoute('groups.addModerator', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('groups.addOwner', { authRequired: true }, {
post: function() {
post() {
const findResult = findPrivateGroupByIdOrName({ roomId: this.bodyParams.roomId, userId: this.userId });
const user = this.getUserFromParams();
@ -52,7 +52,7 @@ RocketChat.API.v1.addRoute('groups.addOwner', { authRequired: true }, {
//Archives a private group only if it wasn't
RocketChat.API.v1.addRoute('groups.archive', { authRequired: true }, {
post: function() {
post() {
const findResult = findPrivateGroupByIdOrName({ roomId: this.bodyParams.roomId, userId: this.userId });
Meteor.runAsUser(this.userId, () => {
@ -64,7 +64,7 @@ RocketChat.API.v1.addRoute('groups.archive', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('groups.close', { authRequired: true }, {
post: function() {
post() {
const findResult = findPrivateGroupByIdOrName({ roomId: this.bodyParams.roomId, userId: this.userId, checkedArchived: false });
if (!findResult.open) {
@ -81,7 +81,7 @@ RocketChat.API.v1.addRoute('groups.close', { authRequired: true }, {
//Create Private Group
RocketChat.API.v1.addRoute('groups.create', { authRequired: true }, {
post: function() {
post() {
if (!RocketChat.authz.hasPermission(this.userId, 'create-p')) {
return RocketChat.API.v1.unauthorized();
}
@ -115,7 +115,7 @@ RocketChat.API.v1.addRoute('groups.create', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('groups.delete', { authRequired: true }, {
post: function() {
post() {
const findResult = findPrivateGroupByIdOrName({ roomId: this.bodyParams.roomId, userId: this.userId, checkedArchived: false });
Meteor.runAsUser(this.userId, () => {
@ -129,7 +129,7 @@ RocketChat.API.v1.addRoute('groups.delete', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('groups.getIntegrations', { authRequired: true }, {
get: function() {
get() {
if (!RocketChat.authz.hasPermission(this.userId, 'manage-integrations')) {
return RocketChat.API.v1.unauthorized();
}
@ -167,7 +167,7 @@ RocketChat.API.v1.addRoute('groups.getIntegrations', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('groups.history', { authRequired: true }, {
get: function() {
get() {
const findResult = findPrivateGroupByIdOrName({ roomId: this.queryParams.roomId, userId: this.userId, checkedArchived: false });
let latestDate = new Date();
@ -207,7 +207,7 @@ RocketChat.API.v1.addRoute('groups.history', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('groups.info', { authRequired: true }, {
get: function() {
get() {
const findResult = findPrivateGroupByIdOrName({ roomId: this.queryParams.roomId, roomName: this.queryParams.roomName, userId: this.userId, checkedArchived: false });
return RocketChat.API.v1.success({
@ -217,7 +217,7 @@ RocketChat.API.v1.addRoute('groups.info', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('groups.invite', { authRequired: true }, {
post: function() {
post() {
const findResult = findPrivateGroupByIdOrName({ roomId: this.bodyParams.roomId, userId: this.userId });
const user = this.getUserFromParams();
@ -233,7 +233,7 @@ RocketChat.API.v1.addRoute('groups.invite', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('groups.kick', { authRequired: true }, {
post: function() {
post() {
const findResult = findPrivateGroupByIdOrName({ roomId: this.bodyParams.roomId, userId: this.userId });
const user = this.getUserFromParams();
@ -247,7 +247,7 @@ RocketChat.API.v1.addRoute('groups.kick', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('groups.leave', { authRequired: true }, {
post: function() {
post() {
const findResult = findPrivateGroupByIdOrName({ roomId: this.bodyParams.roomId, userId: this.userId });
Meteor.runAsUser(this.userId, () => {
@ -260,7 +260,7 @@ RocketChat.API.v1.addRoute('groups.leave', { authRequired: true }, {
//List Private Groups a user has access to
RocketChat.API.v1.addRoute('groups.list', { authRequired: true }, {
get: function() {
get() {
const { offset, count } = this.getPaginationItems();
const { sort, fields } = this.parseJsonQuery();
let rooms = _.pluck(RocketChat.models.Subscriptions.findByTypeAndUserId('p', this.userId).fetch(), '_room');
@ -283,7 +283,7 @@ RocketChat.API.v1.addRoute('groups.list', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('groups.online', { authRequired: true }, {
get: function() {
get() {
const { query } = this.parseJsonQuery();
const ourQuery = Object.assign({}, query, { t: 'p' });
@ -316,7 +316,7 @@ RocketChat.API.v1.addRoute('groups.online', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('groups.open', { authRequired: true }, {
post: function() {
post() {
const findResult = findPrivateGroupByIdOrName({ roomId: this.bodyParams.roomId, userId: this.userId, checkedArchived: false });
if (findResult.open) {
@ -332,7 +332,7 @@ RocketChat.API.v1.addRoute('groups.open', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('groups.removeModerator', { authRequired: true }, {
post: function() {
post() {
const findResult = findPrivateGroupByIdOrName({ roomId: this.bodyParams.roomId, userId: this.userId });
const user = this.getUserFromParams();
@ -346,7 +346,7 @@ RocketChat.API.v1.addRoute('groups.removeModerator', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('groups.removeOwner', { authRequired: true }, {
post: function() {
post() {
const findResult = findPrivateGroupByIdOrName({ roomId: this.bodyParams.roomId, userId: this.userId });
const user = this.getUserFromParams();
@ -360,7 +360,7 @@ RocketChat.API.v1.addRoute('groups.removeOwner', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('groups.rename', { authRequired: true }, {
post: function() {
post() {
if (!this.bodyParams.name || !this.bodyParams.name.trim()) {
return RocketChat.API.v1.failure('The bodyParam "name" is required');
}
@ -378,7 +378,7 @@ RocketChat.API.v1.addRoute('groups.rename', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('groups.setDescription', { authRequired: true }, {
post: function() {
post() {
if (!this.bodyParams.description || !this.bodyParams.description.trim()) {
return RocketChat.API.v1.failure('The bodyParam "description" is required');
}
@ -396,7 +396,7 @@ RocketChat.API.v1.addRoute('groups.setDescription', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('groups.setPurpose', { authRequired: true }, {
post: function() {
post() {
if (!this.bodyParams.purpose || !this.bodyParams.purpose.trim()) {
return RocketChat.API.v1.failure('The bodyParam "purpose" is required');
}
@ -414,7 +414,7 @@ RocketChat.API.v1.addRoute('groups.setPurpose', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('groups.setReadOnly', { authRequired: true }, {
post: function() {
post() {
if (typeof this.bodyParams.readOnly === 'undefined') {
return RocketChat.API.v1.failure('The bodyParam "readOnly" is required');
}
@ -436,7 +436,7 @@ RocketChat.API.v1.addRoute('groups.setReadOnly', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('groups.setTopic', { authRequired: true }, {
post: function() {
post() {
if (!this.bodyParams.topic || !this.bodyParams.topic.trim()) {
return RocketChat.API.v1.failure('The bodyParam "topic" is required');
}
@ -454,7 +454,7 @@ RocketChat.API.v1.addRoute('groups.setTopic', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('groups.setType', { authRequired: true }, {
post: function() {
post() {
if (!this.bodyParams.type || !this.bodyParams.type.trim()) {
return RocketChat.API.v1.failure('The bodyParam "type" is required');
}
@ -476,7 +476,7 @@ RocketChat.API.v1.addRoute('groups.setType', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('groups.unarchive', { authRequired: true }, {
post: function() {
post() {
const findResult = findPrivateGroupByIdOrName({ roomId: this.bodyParams.roomId, userId: this.userId, checkedArchived: false });
Meteor.runAsUser(this.userId, () => {

@ -13,7 +13,7 @@ function findDirectMessageRoomById(roomId, userId) {
}
RocketChat.API.v1.addRoute(['dm.close', 'im.close'], { authRequired: true }, {
post: function() {
post() {
const findResult = findDirectMessageRoomById(this.bodyParams.roomId, this.userId);
//The find method returns either with the dm or the failure
@ -34,7 +34,7 @@ RocketChat.API.v1.addRoute(['dm.close', 'im.close'], { authRequired: true }, {
});
RocketChat.API.v1.addRoute(['dm.history', 'im.history'], { authRequired: true }, {
get: function() {
get() {
const findResult = findDirectMessageRoomById(this.queryParams.roomId, this.userId);
//The find method returns either with the group or the failure
@ -79,7 +79,7 @@ RocketChat.API.v1.addRoute(['dm.history', 'im.history'], { authRequired: true },
});
RocketChat.API.v1.addRoute(['dm.messages.others', 'im.messages.others'], { authRequired: true }, {
get: function() {
get() {
if (RocketChat.settings.get('API_Enable_Direct_Message_History_EndPoint') !== true) {
throw new Meteor.Error('error-endpoint-disabled', 'This endpoint is disabled', { route: '/api/v1/im.messages.others' });
}
@ -119,7 +119,7 @@ RocketChat.API.v1.addRoute(['dm.messages.others', 'im.messages.others'], { authR
});
RocketChat.API.v1.addRoute(['dm.list', 'im.list'], { authRequired: true }, {
get: function() {
get() {
const { offset, count } = this.getPaginationItems();
const { sort, fields } = this.parseJsonQuery();
let rooms = _.pluck(RocketChat.models.Subscriptions.findByTypeAndUserId('d', this.userId).fetch(), '_room');
@ -142,7 +142,7 @@ RocketChat.API.v1.addRoute(['dm.list', 'im.list'], { authRequired: true }, {
});
RocketChat.API.v1.addRoute(['dm.list.everyone', 'im.list.everyone'], { authRequired: true }, {
get: function() {
get() {
if (!RocketChat.authz.hasPermission(this.userId, 'view-room-administration')) {
return RocketChat.API.v1.unauthorized();
}
@ -169,7 +169,7 @@ RocketChat.API.v1.addRoute(['dm.list.everyone', 'im.list.everyone'], { authRequi
});
RocketChat.API.v1.addRoute(['dm.open', 'im.open'], { authRequired: true }, {
post: function() {
post() {
const findResult = findDirectMessageRoomById(this.bodyParams.roomId, this.userId);
//The find method returns either with the group or the failure
@ -190,7 +190,7 @@ RocketChat.API.v1.addRoute(['dm.open', 'im.open'], { authRequired: true }, {
});
RocketChat.API.v1.addRoute(['dm.setTopic', 'im.setTopic'], { authRequired: true }, {
post: function() {
post() {
if (!this.bodyParams.topic || !this.bodyParams.topic.trim()) {
return RocketChat.API.v1.failure('The bodyParam "topic" is required');
}

@ -1,5 +1,5 @@
RocketChat.API.v1.addRoute('integrations.create', { authRequired: true }, {
post: function() {
post() {
check(this.bodyParams, Match.ObjectIncluding({
type: String,
name: String,
@ -35,7 +35,7 @@ RocketChat.API.v1.addRoute('integrations.create', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('integrations.history', { authRequired: true }, {
get: function() {
get() {
if (!RocketChat.authz.hasPermission(this.userId, 'manage-integrations')) {
return RocketChat.API.v1.unauthorized();
}
@ -66,7 +66,7 @@ RocketChat.API.v1.addRoute('integrations.history', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('integrations.list', { authRequired: true }, {
get: function() {
get() {
if (!RocketChat.authz.hasPermission(this.userId, 'manage-integrations')) {
return RocketChat.API.v1.unauthorized();
}
@ -83,7 +83,7 @@ RocketChat.API.v1.addRoute('integrations.list', { authRequired: true }, {
}).fetch();
return RocketChat.API.v1.success({
integrations: integrations,
integrations,
offset,
items: integrations.length,
total: RocketChat.models.Integrations.find(ourQuery).count()
@ -92,7 +92,7 @@ RocketChat.API.v1.addRoute('integrations.list', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('integrations.remove', { authRequired: true }, {
post: function() {
post() {
check(this.bodyParams, Match.ObjectIncluding({
type: String,
target_url: Match.Maybe(String),
@ -122,7 +122,7 @@ RocketChat.API.v1.addRoute('integrations.remove', { authRequired: true }, {
});
return RocketChat.API.v1.success({
integration: integration
integration
});
default:
return RocketChat.API.v1.failure('Invalid integration type.');

@ -1,5 +1,5 @@
RocketChat.API.v1.addRoute('info', { authRequired: false }, {
get: function() {
get() {
const user = this.getLoggedInUser();
if (user && RocketChat.authz.hasRole(user._id, 'admin')) {
@ -17,7 +17,7 @@ RocketChat.API.v1.addRoute('info', { authRequired: false }, {
});
RocketChat.API.v1.addRoute('me', { authRequired: true }, {
get: function() {
get() {
return RocketChat.API.v1.success(_.pick(this.user, [
'_id',
'name',

@ -1,5 +1,5 @@
RocketChat.API.v1.addRoute('users.create', { authRequired: true }, {
post: function() {
post() {
check(this.bodyParams, {
email: String,
name: String,
@ -36,7 +36,7 @@ RocketChat.API.v1.addRoute('users.create', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('users.delete', { authRequired: true }, {
post: function() {
post() {
if (!RocketChat.authz.hasPermission(this.userId, 'delete-user')) {
return RocketChat.API.v1.unauthorized();
}
@ -52,7 +52,7 @@ RocketChat.API.v1.addRoute('users.delete', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('users.getAvatar', { authRequired: false }, {
get: function() {
get() {
const user = this.getUserFromParams();
const url = RocketChat.getURL(`/avatar/${user.username}`, { cdn: false, full: true });
@ -66,7 +66,7 @@ RocketChat.API.v1.addRoute('users.getAvatar', { authRequired: false }, {
});
RocketChat.API.v1.addRoute('users.getPresence', { authRequired: true }, {
get: function() {
get() {
//BLAHHHHHHHHHH :'(
if ((this.queryParams.userId && this.userId !== this.queryParams.userId) || (this.queryParams.username && this.user.username !== this.queryParams.username) || (this.queryParams.user && this.user.username !== this.queryParams.user)) {
const user = this.getUserFromParams();
@ -86,7 +86,7 @@ RocketChat.API.v1.addRoute('users.getPresence', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('users.info', { authRequired: true }, {
get: function() {
get() {
const user = this.getUserFromParams();
let result;
@ -105,7 +105,7 @@ RocketChat.API.v1.addRoute('users.info', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('users.list', { authRequired: true }, {
get: function() {
get() {
const { offset, count } = this.getPaginationItems();
const { sort, fields, query } = this.parseJsonQuery();
@ -148,7 +148,7 @@ RocketChat.API.v1.addRoute('users.list', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('users.register', { authRequired: false }, {
post: function() {
post() {
if (this.userId) {
return RocketChat.API.v1.failure('Logged in users can not register again.');
}
@ -171,7 +171,7 @@ RocketChat.API.v1.addRoute('users.register', { authRequired: false }, {
//TODO: Make this route work with support for usernames
RocketChat.API.v1.addRoute('users.setAvatar', { authRequired: true }, {
post: function() {
post() {
check(this.bodyParams, { avatarUrl: Match.Maybe(String), userId: Match.Maybe(String) });
if (typeof this.bodyParams.userId !== 'undefined' && this.userId !== this.bodyParams.userId && !RocketChat.authz.hasPermission(this.userId, 'edit-other-user-info')) {
@ -212,7 +212,7 @@ RocketChat.API.v1.addRoute('users.setAvatar', { authRequired: true }, {
});
RocketChat.API.v1.addRoute('users.update', { authRequired: true }, {
post: function() {
post() {
check(this.bodyParams, {
userId: String,
data: Match.ObjectIncluding({

@ -268,12 +268,12 @@ RocketChat.Assets = new (class {
where: 'client',
type: 'asset',
content: file.buffer,
extension: extension,
extension,
url: `/assets/${assetKey}.${extension}?${hash}`,
size: file.length,
uploadDate: file.uploadDate,
contentType: file.contentType,
hash: hash
hash
};
}
});

@ -3,7 +3,7 @@ Meteor.subscribe('roles');
RocketChat.AdminBox.addOption({
href: 'admin-permissions',
i18nLabel: 'Permissions',
permissionGranted: function() {
permissionGranted() {
return RocketChat.authz.hasAllPermission('access-permissions');
}
});

@ -65,7 +65,7 @@ Template.permissionsRole.helpers({
noMatchTemplate: Template.roomSearchEmpty,
matchAll: true,
sort: 'name',
selector: function(match) {
selector(match) {
return {
name: match
};
@ -90,7 +90,7 @@ Template.permissionsRole.helpers({
filter: {
exceptions: instance.usersInRole.get() && instance.usersInRole.get().fetch()
},
selector: function(match) {
selector(match) {
return {
term: match
};

@ -40,9 +40,9 @@ Meteor.methods({
_id: roleName,
u: {
_id: user._id,
username: username
username
},
scope: scope
scope
});
}

@ -14,7 +14,7 @@ Meteor.methods({
}
const user = Meteor.users.findOne({
username: username
username
}, {
fields: {
_id: 1,
@ -52,9 +52,9 @@ Meteor.methods({
_id: roleName,
u: {
_id: user._id,
username: username
username
},
scope: scope
scope
});
}

@ -34,7 +34,7 @@ RocketChat.models._Base.prototype.removeRolesByUserId = function(userId, roles,
const query = this.roleBaseQuery(userId, scope);
const update = {
$pullAll: {
roles: roles
roles
}
};
return this.update(query, update);

@ -17,7 +17,7 @@ class ModelPermissions extends RocketChat.models._Base {
}
createOrUpdate(name, roles) {
this.upsert({ _id: name }, { $set: { roles: roles } });
this.upsert({ _id: name }, { $set: { roles } });
}
addRole(permission, role) {

@ -10,7 +10,7 @@ Meteor.publish('usersInRole', function(roleName, scope, limit = 50) {
}
const options = {
limit: limit,
limit,
sort: {
name: 1
}

@ -5,7 +5,7 @@ RocketChat.AutoTranslate = {
getLanguage(rid) {
let subscription = {};
if (rid) {
subscription = RocketChat.models.Subscriptions.findOne({ rid: rid }, { fields: { autoTranslateLanguage: 1 } });
subscription = RocketChat.models.Subscriptions.findOne({ rid }, { fields: { autoTranslateLanguage: 1 } });
}
const language = subscription && subscription.autoTranslateLanguage || Meteor.user().language || window.defaultUserLanguage();
if (language.indexOf('-') !== -1) {

@ -30,7 +30,7 @@ class AutoTranslate {
message.msg = message.msg.replace(/:[+\w\d]+:/g, function(match) {
const token = `<i class=notranslate>{${count++}}</i>`;
message.tokens.push({
token: token,
token,
text: match
});
return token;
@ -120,7 +120,7 @@ class AutoTranslate {
message.msg = message.msg.replace(new RegExp(`(@${mention.username})`, 'gm'), match => {
const token = `<i class=notranslate>{${count++}}</i>`;
message.tokens.push({
token: token,
token,
text: match
});
return token;
@ -133,7 +133,7 @@ class AutoTranslate {
message.msg = message.msg.replace(new RegExp(`(#${channel.name})`, 'gm'), match => {
const token = `<i class=notranslate>{${count++}}</i>`;
message.tokens.push({
token: token,
token,
text: match
});
return token;
@ -180,7 +180,7 @@ class AutoTranslate {
}
let result;
try {
result = HTTP.get('https://translation.googleapis.com/language/translate/v2', { params: { key: this.apiKey, target: language }, query: query });
result = HTTP.get('https://translation.googleapis.com/language/translate/v2', { params: { key: this.apiKey, target: language }, query });
} catch (e) {
console.log('Error translating message', e);
return message;
@ -209,7 +209,7 @@ class AutoTranslate {
if (language.indexOf('-') !== -1 && !_.findWhere(supportedLanguages, { language })) {
language = language.substr(0, 2);
}
const result = HTTP.get('https://translation.googleapis.com/language/translate/v2', { params: { key: this.apiKey, target: language }, query: query });
const result = HTTP.get('https://translation.googleapis.com/language/translate/v2', { params: { key: this.apiKey, target: language }, query });
if (result.statusCode === 200 && result.data && result.data.data && result.data.data.translations && Array.isArray(result.data.data.translations) && result.data.data.translations.length > 0) {
const txt = result.data.data.translations.map(translation => translation.translatedText).join('\n');
translations[language] = txt;
@ -240,13 +240,13 @@ class AutoTranslate {
}
try {
result = HTTP.get('https://translation.googleapis.com/language/translate/v2/languages', { params: params });
result = HTTP.get('https://translation.googleapis.com/language/translate/v2/languages', { params });
} catch (e) {
if (e.response && e.response.statusCode === 400 && e.response.data && e.response.data.error && e.response.data.error.status === 'INVALID_ARGUMENT') {
params.target = 'en';
target = 'en';
if (!this.supportedLanguages[target]) {
result = HTTP.get('https://translation.googleapis.com/language/translate/v2/languages', { params: params });
result = HTTP.get('https://translation.googleapis.com/language/translate/v2/languages', { params });
}
}
} finally {

@ -1,5 +1,5 @@
Meteor.methods({
'autoTranslate.saveSettings': function(rid, field, value, options) {
'autoTranslate.saveSettings'(rid, field, value, options) {
if (!Meteor.userId()) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'saveAutoTranslateSettings' });
}

@ -1,13 +1,13 @@
RocketChat.models.Subscriptions.updateAutoTranslateById = function(_id, autoTranslate) {
const query = {
_id: _id
_id
};
let update;
if (autoTranslate) {
update = {
$set: {
autoTranslate: autoTranslate
autoTranslate
}
};
} else {
@ -23,12 +23,12 @@ RocketChat.models.Subscriptions.updateAutoTranslateById = function(_id, autoTran
RocketChat.models.Subscriptions.updateAutoTranslateLanguageById = function(_id, autoTranslateLanguage) {
const query = {
_id: _id
_id
};
const update = {
$set: {
autoTranslateLanguage: autoTranslateLanguage
autoTranslateLanguage
}
};
@ -39,7 +39,7 @@ RocketChat.models.Subscriptions.getAutoTranslateLanguagesByRoomAndNotUser = func
const subscriptionsRaw = RocketChat.models.Subscriptions.model.rawCollection();
const distinct = Meteor.wrapAsync(subscriptionsRaw.distinct, subscriptionsRaw);
const query = {
rid: rid,
rid,
'u._id': { $ne: userId },
autoTranslate: true
};

@ -52,7 +52,7 @@ Meteor.loginWithCas = function(options, callback) {
popup.addEventListener('exit', function() {
// check auth on server.
Accounts.callLoginMethod({
methodArguments: [{ cas: { credentialToken: credentialToken } }],
methodArguments: [{ cas: { credentialToken } }],
userCallback: callback
});
});
@ -77,7 +77,7 @@ Meteor.loginWithCas = function(options, callback) {
// check auth on server.
Accounts.callLoginMethod({
methodArguments: [{ cas: { credentialToken: credentialToken } }],
methodArguments: [{ cas: { credentialToken } }],
userCallback: callback
});
}

@ -42,7 +42,7 @@ const casTicket = function(req, token, callback) {
logger.error('error when trying to validate: ' + err.message);
} else if (status) {
logger.info('Validated user: ' + username);
const user_info = { username: username };
const user_info = { username };
// CAS 2.0 attributes handling
if (details && details.attributes) {

@ -9,12 +9,12 @@ Meteor.loginWithCrowd = function(username, password, callback) {
password = args.shift();
const loginRequest = {
crowd: true,
username: username,
username,
crowdPassword: password
};
Accounts.callLoginMethod({
methodArguments: [loginRequest],
userCallback: function(error) {
userCallback(error) {
if (error) {
if (callback) {
callback(error);

@ -5,7 +5,7 @@ const logger = new Logger('CROWD', {});
function fallbackDefaultAccountSystem(bind, username, password) {
if (typeof username === 'string') {
if (username.indexOf('@') === -1) {
username = {username: username};
username = {username};
} else {
username = {email: username};
}
@ -76,7 +76,7 @@ const CROWD = class CROWD {
displayname: userResponse['display-name'],
username: userResponse.name,
email: userResponse.email,
password: password,
password,
active: userResponse.active
};
@ -222,7 +222,7 @@ RocketChat.settings.get('CROWD_Sync_User_Data', function(key, value) {
});
Meteor.methods({
crowd_test_connection:function() {
crowd_test_connection() {
const user = Meteor.user();
if (!user) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'crowd_test_connection' });

@ -2,11 +2,11 @@ Meteor.startup(function() {
RocketChat.settings.addGroup('AtlassianCrowd', function() {
const enableQuery = {_id: 'CROWD_Enable', value: true};
this.add('CROWD_Enable', false, { type: 'boolean', public: true, i18nLabel: 'Enabled' });
this.add('CROWD_URL', '', { type: 'string', enableQuery: enableQuery, i18nLabel: 'URL' });
this.add('CROWD_Reject_Unauthorized', true, { type: 'boolean', enableQuery: enableQuery });
this.add('CROWD_APP_USERNAME', '', { type: 'string', enableQuery: enableQuery, i18nLabel: 'Username' });
this.add('CROWD_APP_PASSWORD', '', { type: 'password', enableQuery: enableQuery, i18nLabel: 'Password' });
this.add('CROWD_Sync_User_Data', false, { type: 'boolean', enableQuery: enableQuery, i18nLabel: 'Sync_Users' });
this.add('CROWD_URL', '', { type: 'string', enableQuery, i18nLabel: 'URL' });
this.add('CROWD_Reject_Unauthorized', true, { type: 'boolean', enableQuery });
this.add('CROWD_APP_USERNAME', '', { type: 'string', enableQuery, i18nLabel: 'Username' });
this.add('CROWD_APP_PASSWORD', '', { type: 'password', enableQuery, i18nLabel: 'Password' });
this.add('CROWD_Sync_User_Data', false, { type: 'boolean', enableQuery, i18nLabel: 'Sync_Users' });
this.add('CROWD_Test_Connection', 'crowd_test_connection', { type: 'action', actionText: 'Test_Connection', i18nLabel: 'Test_Connection' });
});
});

@ -87,10 +87,10 @@ export class CustomOAuth {
OAuth.launchLogin({
loginService: this.name,
loginStyle: loginStyle,
loginUrl: loginUrl,
credentialRequestCompleteCallback: credentialRequestCompleteCallback,
credentialToken: credentialToken,
loginStyle,
loginUrl,
credentialRequestCompleteCallback,
credentialToken,
popupOptions: {
width: 900,
height: 450

@ -119,8 +119,8 @@ export class CustomOAuth {
try {
const response = HTTP.get(this.identityPath, {
headers: headers,
params: params
headers,
params
});
let data;
@ -199,13 +199,13 @@ export class CustomOAuth {
const serviceData = {
_OAuthCustom: true,
accessToken: accessToken
accessToken
};
_.extend(serviceData, identity);
const data = {
serviceData: serviceData,
serviceData,
options: {
profile: {
name: identity.name || identity.username || identity.nickname || identity.CharacterName || identity.userName || identity.preferred_username || (identity.user && identity.user.name)

@ -82,7 +82,7 @@ Template.adminSounds.onCreated(function() {
const limit = (instance.limit != null) ? instance.limit.get() : 0;
return RocketChat.models.CustomSounds.find(query, { limit: limit, sort: { name: 1 }}).fetch();
return RocketChat.models.CustomSounds.find(query, { limit, sort: { name: 1 }}).fetch();
};
});

@ -78,7 +78,7 @@ Template.adminEmoji.onCreated(function() {
const limit = (instance.limit != null) ? instance.limit.get() : 0;
return RocketChat.models.EmojiCustom.find(query, { limit: limit, sort: { name: 1 }}).fetch();
return RocketChat.models.EmojiCustom.find(query, { limit, sort: { name: 1 }}).fetch();
};
});

@ -4,7 +4,7 @@ RocketChat.emoji.packages.emojiCustom = {
toneList: {},
list: [],
render: function(html) {
render(html) {
const regShortNames = new RegExp('<object[^>]*>.*?<\/object>|<span[^>]*>.*?<\/span>|<(?:object|embed|svg|img|div|span|p|a)[^>]*>|(' + RocketChat.emoji.packages.emojiCustom.list.join('|') + ')', 'gi');
// replace regular shortnames first

@ -150,7 +150,7 @@ Template.emojiPicker.helpers({
activeCategory(category) {
return Template.instance().currentCategory.get() === category ? 'active' : '';
},
categoryName: categoryName,
categoryName,
/**
* Returns currently active emoji category hash
*

@ -56,8 +56,8 @@ RocketChat.EmojiPicker = {
const left = sourcePos.left;
const top = (sourcePos.top - this.height - 5);
const cssProperties = {
top: top,
left: left
top,
left
};
if (top < 0) {

@ -3,7 +3,7 @@
import filesize from 'filesize';
const slingShotConfig = {
authorize: function(file/*, metaContext*/) {
authorize(file/*, metaContext*/) {
//Deny uploads if user is not logged in.
if (!this.userId) {
throw new Meteor.Error('login-required', 'Please login before posting files');

@ -2,13 +2,13 @@
/* exported FileUploadBase */
UploadFS.config.defaultStorePermissions = new UploadFS.StorePermissions({
insert: function(userId/*, doc*/) {
insert(userId/*, doc*/) {
return userId;
},
update: function(userId, doc) {
update(userId, doc) {
return RocketChat.authz.hasPermission(Meteor.userId(), 'delete-message', doc.rid) || (RocketChat.settings.get('Message_AllowDeleting') && userId === doc.userId);
},
remove: function(userId, doc) {
remove(userId, doc) {
return RocketChat.authz.hasPermission(Meteor.userId(), 'delete-message', doc.rid) || (RocketChat.settings.get('Message_AllowDeleting') && userId === doc.userId);
}
});

@ -58,10 +58,10 @@ const createS3Directive = _.debounce(() => {
delete Slingshot._directives[directiveName];
}
const config = {
bucket: bucket,
bucket,
AWSAccessKeyId: accessKey,
AWSSecretAccessKey: secretKey,
key: function(file, metaContext) {
key(file, metaContext) {
const path = RocketChat.hostname + '/' + metaContext.rid + '/' + this.userId + '/';
const upload = { s3: {

@ -16,7 +16,7 @@ const createFileSystemStore = _.debounce(function() {
filter: new UploadFS.Filter({
onCheck: FileUpload.validateFileUpload
}),
transformWrite: function(readStream, writeStream, fileId, file) {
transformWrite(readStream, writeStream, fileId, file) {
if (RocketChatFile.enabled === false || !/^image\/((x-windows-)?bmp|p?jpeg|png)$/.test(file.type)) {
return readStream.pipe(writeStream);
}

@ -6,9 +6,9 @@ RocketChat.settings.addGroup('OAuth', function() {
};
this.add('Accounts_OAuth_GitHub_Enterprise', false, { type: 'boolean' });
this.add('API_GitHub_Enterprise_URL', '', { type: 'string', public: true, enableQuery: enableQuery, i18nDescription: 'API_GitHub_Enterprise_URL_Description' });
this.add('Accounts_OAuth_GitHub_Enterprise_id', '', { type: 'string', enableQuery: enableQuery });
this.add('Accounts_OAuth_GitHub_Enterprise_secret', '', { type: 'string', enableQuery: enableQuery });
this.add('Accounts_OAuth_GitHub_Enterprise_callback_url', '_oauth/github_enterprise', { type: 'relativeUrl', readonly: true, force: true, enableQuery: enableQuery });
this.add('API_GitHub_Enterprise_URL', '', { type: 'string', public: true, enableQuery, i18nDescription: 'API_GitHub_Enterprise_URL_Description' });
this.add('Accounts_OAuth_GitHub_Enterprise_id', '', { type: 'string', enableQuery });
this.add('Accounts_OAuth_GitHub_Enterprise_secret', '', { type: 'string', enableQuery });
this.add('Accounts_OAuth_GitHub_Enterprise_callback_url', '_oauth/github_enterprise', { type: 'relativeUrl', readonly: true, force: true, enableQuery });
});
});

@ -6,9 +6,9 @@ RocketChat.settings.addGroup('OAuth', function() {
};
this.add('Accounts_OAuth_Gitlab', false, { type: 'boolean', public: true });
this.add('API_Gitlab_URL', '', { type: 'string', enableQuery: enableQuery, public: true });
this.add('Accounts_OAuth_Gitlab_id', '', { type: 'string', enableQuery: enableQuery });
this.add('Accounts_OAuth_Gitlab_secret', '', { type: 'string', enableQuery: enableQuery });
this.add('Accounts_OAuth_Gitlab_callback_url', '_oauth/gitlab', { type: 'relativeUrl', readonly: true, force: true, enableQuery: enableQuery });
this.add('API_Gitlab_URL', '', { type: 'string', enableQuery, public: true });
this.add('Accounts_OAuth_Gitlab_id', '', { type: 'string', enableQuery });
this.add('Accounts_OAuth_Gitlab_secret', '', { type: 'string', enableQuery });
this.add('Accounts_OAuth_Gitlab_callback_url', '_oauth/gitlab', { type: 'relativeUrl', readonly: true, force: true, enableQuery });
});
});

@ -89,7 +89,7 @@ class IframeLogin {
if (Match.test(token, String)) {
token = {
token: token
token
};
}
@ -166,7 +166,7 @@ window.addEventListener('message', (e) => {
console.log('facebook-login-success', response);
e.source.postMessage({
event: 'facebook-login-success',
response: response
response
// authResponse: Object
// accessToken: "a7s6d8a76s8d7..."
// expiresIn: "5172793"
@ -182,8 +182,8 @@ window.addEventListener('message', (e) => {
console.log('facebook-login-error', error, response);
e.source.postMessage({
event: 'facebook-login-error',
error: error,
response: response
error,
response
}, e.origin);
};
@ -196,7 +196,7 @@ window.addEventListener('message', (e) => {
authResponse: {
accessToken: serviceData.accessToken,
expiresIn: serviceData.expiresAt,
secret: secret
secret
},
userID: serviceData.id
});
@ -223,7 +223,7 @@ window.addEventListener('message', (e) => {
console.log('twitter-login-success', response);
e.source.postMessage({
event: 'twitter-login-success',
response: response
response
// {
// "userName": "orodrigok",
// "userId": 293123,
@ -237,7 +237,7 @@ window.addEventListener('message', (e) => {
console.log('twitter-login-error', error);
e.source.postMessage({
event: 'twitter-login-error',
error: error
error
}, e.origin);
};
@ -269,7 +269,7 @@ window.addEventListener('message', (e) => {
console.log('google-login-success', response);
e.source.postMessage({
event: 'google-login-success',
response: response
response
// {
// "email": "rodrigoknascimento@gmail.com",
// "userId": "1082039180239",
@ -288,7 +288,7 @@ window.addEventListener('message', (e) => {
console.log('google-login-error', error);
e.source.postMessage({
event: 'google-login-error',
error: error
error
}, e.origin);
};

@ -221,7 +221,7 @@ Template.integrationsIncoming.events({
const integration = {
enabled: enabled === '1',
channel: channel,
channel,
alias: alias !== '' ? alias : undefined,
emoji: emoji !== '' ? emoji : undefined,
avatar: avatar !== '' ? avatar : undefined,

@ -322,7 +322,7 @@ Template.integrationsOutgoing.events({
const integration = {
event: event !== '' ? event : undefined,
enabled: enabled === '1',
username: username,
username,
channel: channel !== '' ? channel : undefined,
targetRoom: targetRoom !== '' ? targetRoom : undefined,
alias: alias !== '' ? alias : undefined,

@ -69,7 +69,7 @@ this.processWebhookMessage = function(messageObj, user, defaultValues = { channe
}
const messageReturn = RocketChat.sendMessage(user, message, room);
sentData.push({ channel: channel, message: messageReturn });
sentData.push({ channel, message: messageReturn });
}
return sentData;

@ -30,7 +30,7 @@ Meteor.loginWithLDAP = function(username, password, customLdapOptions, callback)
// Set up loginRequest object
const loginRequest = {
ldap: true,
username: username,
username,
ldapPass: password,
ldapOptions: customLdapOptions
};
@ -39,7 +39,7 @@ Meteor.loginWithLDAP = function(username, password, customLdapOptions, callback)
// Call login method with ldap = true
// This will hook into our login handler for ldap
methodArguments: [loginRequest],
userCallback: function(error/*, result*/) {
userCallback(error/*, result*/) {
if (error) {
if (callback) {
callback(error);

@ -250,7 +250,7 @@ LDAP = class LDAP {
if (attribute) {
filter = new self.ldapjs.filters.EqualityFilter({
attribute: attribute,
attribute,
value: new Buffer(id, 'hex')
});
} else {
@ -262,11 +262,11 @@ LDAP = class LDAP {
}));
});
filter = new self.ldapjs.filters.OrFilter({filters: filters});
filter = new self.ldapjs.filters.OrFilter({filters});
}
const searchOptions = {
filter: filter,
filter,
scope: 'sub'
};

@ -6,7 +6,7 @@ const logger = new Logger('LDAPHandler', {});
function fallbackDefaultAccountSystem(bind, username, password) {
if (typeof username === 'string') {
if (username.indexOf('@') === -1) {
username = {username: username};
username = {username};
} else {
username = {email: username};
}
@ -99,7 +99,7 @@ Accounts.registerLoginHandler('ldap', function(loginRequest) {
if (!user) {
userQuery = {
username: username
username
};
logger.debug('userQuery', userQuery);

@ -23,21 +23,21 @@ Meteor.startup(function() {
];
this.add('LDAP_Enable', false, { type: 'boolean', public: true });
this.add('LDAP_Login_Fallback', true, { type: 'boolean', enableQuery: enableQuery });
this.add('LDAP_Host', '', { type: 'string', enableQuery: enableQuery });
this.add('LDAP_Port', '389', { type: 'string', enableQuery: enableQuery });
this.add('LDAP_Connect_Timeout', 600000, {type: 'int', enableQuery: enableQuery});
this.add('LDAP_Idle_Timeout', 600000, {type: 'int', enableQuery: enableQuery});
this.add('LDAP_Encryption', 'plain', { type: 'select', values: [ { key: 'plain', i18nLabel: 'No_Encryption' }, { key: 'tls', i18nLabel: 'StartTLS' }, { key: 'ssl', i18nLabel: 'SSL/LDAPS' } ], enableQuery: enableQuery });
this.add('LDAP_Login_Fallback', true, { type: 'boolean', enableQuery });
this.add('LDAP_Host', '', { type: 'string', enableQuery });
this.add('LDAP_Port', '389', { type: 'string', enableQuery });
this.add('LDAP_Connect_Timeout', 600000, {type: 'int', enableQuery});
this.add('LDAP_Idle_Timeout', 600000, {type: 'int', enableQuery});
this.add('LDAP_Encryption', 'plain', { type: 'select', values: [ { key: 'plain', i18nLabel: 'No_Encryption' }, { key: 'tls', i18nLabel: 'StartTLS' }, { key: 'ssl', i18nLabel: 'SSL/LDAPS' } ], enableQuery });
this.add('LDAP_CA_Cert', '', { type: 'string', multiline: true, enableQuery: enableTLSQuery });
this.add('LDAP_Reject_Unauthorized', true, { type: 'boolean', enableQuery: enableTLSQuery });
this.add('LDAP_Domain_Base', '', { type: 'string', enableQuery: enableQuery });
this.add('LDAP_Use_Custom_Domain_Search', false, { type: 'boolean', enableQuery: enableQuery });
this.add('LDAP_Domain_Base', '', { type: 'string', enableQuery });
this.add('LDAP_Use_Custom_Domain_Search', false, { type: 'boolean', enableQuery });
this.add('LDAP_Custom_Domain_Search', '', { type: 'string', enableQuery: customBindSearchEnabledQuery });
this.add('LDAP_Domain_Search_User', '', { type: 'string', enableQuery: customBindSearchDisabledQuery });
this.add('LDAP_Domain_Search_Password', '', { type: 'password', enableQuery: customBindSearchDisabledQuery });
this.add('LDAP_Domain_Search_Filter', '', { type: 'string', enableQuery: customBindSearchDisabledQuery });
this.add('LDAP_Group_Filter_Enable', false, { type: 'boolean', enableQuery: enableQuery });
this.add('LDAP_Group_Filter_Enable', false, { type: 'boolean', enableQuery });
this.add('LDAP_Group_Filter_ObjectClass', 'groupOfUniqueNames', { type: 'string', enableQuery: groupFilterQuery });
this.add('LDAP_Group_Filter_Group_Id_Attribute', 'cn', { type: 'string', enableQuery: groupFilterQuery });
this.add('LDAP_Group_Filter_Group_Member_Attribute', 'uniqueMember', { type: 'string', enableQuery: groupFilterQuery });
@ -46,13 +46,13 @@ Meteor.startup(function() {
this.add('LDAP_Domain_Search_User_ID', 'sAMAccountName', { type: 'string', enableQuery: customBindSearchDisabledQuery });
this.add('LDAP_Domain_Search_Object_Class', 'user', { type: 'string', enableQuery: customBindSearchDisabledQuery });
this.add('LDAP_Domain_Search_Object_Category', 'person', { type: 'string', enableQuery: customBindSearchDisabledQuery });
this.add('LDAP_Username_Field', 'sAMAccountName', { type: 'string', enableQuery: enableQuery });
this.add('LDAP_Unique_Identifier_Field', 'objectGUID,ibm-entryUUID,GUID,dominoUNID,nsuniqueId,uidNumber', { type: 'string', enableQuery: enableQuery });
this.add('LDAP_Sync_User_Data', false, { type: 'boolean', enableQuery: enableQuery });
this.add('LDAP_Username_Field', 'sAMAccountName', { type: 'string', enableQuery });
this.add('LDAP_Unique_Identifier_Field', 'objectGUID,ibm-entryUUID,GUID,dominoUNID,nsuniqueId,uidNumber', { type: 'string', enableQuery });
this.add('LDAP_Sync_User_Data', false, { type: 'boolean', enableQuery });
this.add('LDAP_Sync_User_Avatar', true, { type: 'boolean', enableQuery: syncDataQuery });
this.add('LDAP_Sync_User_Data_FieldMap', '{"cn":"name", "mail":"email"}', { type: 'string', enableQuery: syncDataQuery });
this.add('LDAP_Default_Domain', '', { type: 'string', enableQuery: enableQuery });
this.add('LDAP_Merge_Existing_Users', false, { type: 'boolean', enableQuery: enableQuery });
this.add('LDAP_Default_Domain', '', { type: 'string', enableQuery });
this.add('LDAP_Merge_Existing_Users', false, { type: 'boolean', enableQuery });
this.add('LDAP_Import_Users', false, { type: 'boolean', enableQuery: syncDataQuery });
this.add('LDAP_Test_Connection', 'ldap_test_connection', { type: 'action', actionText: 'Test_Connection' });
this.add('LDAP_Sync_Users', 'ldap_sync_users', { type: 'action', actionText: 'Sync_Users' });

@ -155,7 +155,7 @@ syncUserData = function syncUserData(user, ldapUser) {
addLdapUser = function addLdapUser(ldapUser, username, password) {
const userObject = {
username: username
username
};
const userData = getDataToSyncUserData(ldapUser, {});
@ -210,7 +210,7 @@ sync = function sync() {
const username = slug(getLdapUsername(ldapUser));
// Look to see if user already exists
const userQuery = {
username: username
username
};
logger.debug('userQuery', userQuery);

@ -1,7 +1,7 @@
/* globals sync */
Meteor.methods({
ldap_sync_users: function() {
ldap_sync_users() {
const user = Meteor.user();
if (!user) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'ldap_sync_users' });

@ -1,7 +1,7 @@
/* globals LDAP */
Meteor.methods({
ldap_test_connection: function() {
ldap_test_connection() {
const user = Meteor.user();
if (!user) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'ldap_test_connection' });

@ -42,7 +42,7 @@ RocketChat.createRoom = function(type, name, owner, members, readOnly, extraData
if (type === 'c') {
RocketChat.callbacks.run('beforeCreateChannel', owner, {
t: 'c',
name: name,
name,
ts: now,
ro: readOnly === true,
sysMes: readOnly !== true,

@ -33,8 +33,8 @@ RocketChat.getFullUserData = function({userId, filter, limit}) {
}
const options = {
fields: fields,
limit: limit,
fields,
limit,
sort: { username: 1 }
};

@ -81,7 +81,7 @@ RocketChat.saveUser = function(userId, userData) {
updateUser.$set['emails.0.verified'] = true;
}
Meteor.users.update({ _id: _id }, updateUser);
Meteor.users.update({ _id }, updateUser);
if (userData.sendWelcomeEmail) {
const header = RocketChat.placeholders.replace(RocketChat.settings.get('Email_Header') || '');
@ -108,7 +108,7 @@ RocketChat.saveUser = function(userId, userData) {
const email = {
to: userData.email,
from: RocketChat.settings.get('From_Email'),
subject: subject,
subject,
html: header + html + footer
};

@ -29,5 +29,5 @@ RocketChat._setEmail = function(userId, email) {
};
RocketChat.setEmail = RocketChat.RateLimiter.limitFunction(RocketChat._setEmail, 1, 60000, {
0: function(userId) { return !userId || !RocketChat.authz.hasPermission(userId, 'edit-other-user-info'); } // Administrators have permission to change others emails, so don't limit those
0(userId) { return !userId || !RocketChat.authz.hasPermission(userId, 'edit-other-user-info'); } // Administrators have permission to change others emails, so don't limit those
});

@ -12,7 +12,7 @@ RocketChat.updateMessage = function(message, user) {
const urls = message.msg.match(/([A-Za-z]{3,9}):\/\/([-;:&=\+\$,\w]+@{1})?([-A-Za-z0-9\.]+)+:?(\d+)?((\/[-\+=!:~%\/\.@\,\w]*)?\??([-\+=&!:;%@\/\.\,\w]+)?(?:#([^\s\)]+))?)?/g);
if (urls) {
message.urls = urls.map((url) => { return { url: url }; });
message.urls = urls.map((url) => { return { url }; });
}
message = RocketChat.callbacks.run('beforeSaveMessage', message);

@ -29,7 +29,7 @@ class PushNotification {
from: 'push',
badge: 1,
sound: 'default',
title: title,
title,
text: message,
payload,
query: usersTo,

@ -278,7 +278,7 @@ RocketChat.callbacks.add('afterSaveMessage', function(message, room) {
title += ' @ #' + room.name;
}
RocketChat.Notifications.notifyUser(usersOfMentionId, 'notification', {
title: title,
title,
text: message.msg,
duration: settings.desktopNotificationDurations[usersOfMentionId],
payload: {

@ -21,7 +21,7 @@ RocketChat.settings.get('Accounts_UseDNSDomainCheck', function(key, value) {
RocketChat.validateEmailDomain = function(email) {
const emailValidation = /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
if (!emailValidation.test(email)) {
throw new Meteor.Error('error-invalid-email', 'Invalid email ' + email, { function: 'RocketChat.validateEmailDomain', email: email });
throw new Meteor.Error('error-invalid-email', 'Invalid email ' + email, { function: 'RocketChat.validateEmailDomain', email });
}
const emailDomain = email.substr(email.lastIndexOf('@') + 1);

@ -1,5 +1,5 @@
Meteor.methods({
addUserToRoom: function(data) {
addUserToRoom(data) {
return Meteor.call('addUsersToRoom', {
rid: data.rid,
users: [ data.username ]

@ -1,5 +1,5 @@
Meteor.methods({
deleteUserOwnAccount: function(password) {
deleteUserOwnAccount(password) {
check(password, String);

@ -1,5 +1,5 @@
Meteor.methods({
saveSetting: function(_id, value, editor) {
saveSetting(_id, value, editor) {
if (Meteor.userId() === null) {
throw new Meteor.Error('error-action-not-allowed', 'Editing settings is not allowed', {
method: 'saveSetting'

@ -1,5 +1,5 @@
Meteor.methods({
setEmail: function(email) {
setEmail(email) {
check (email, String);
@ -26,5 +26,5 @@ Meteor.methods({
});
RocketChat.RateLimiter.limitMethod('setEmail', 1, 1000, {
userId: function(/*userId*/) { return true; }
userId(/*userId*/) { return true; }
});

@ -173,27 +173,27 @@ class ModelsBaseCache extends EventEmitter {
}
RocketChat.models[join].cache.on('inserted', (record) => {
this.processRemoteJoinInserted({join, field, link, multi, record: record});
this.processRemoteJoinInserted({join, field, link, multi, record});
});
RocketChat.models[join].cache.on('beforeupdate', (record, diff) => {
if (diff[link.remote]) {
this.processRemoteJoinRemoved({join, field, link, multi, record: record});
this.processRemoteJoinRemoved({join, field, link, multi, record});
}
});
RocketChat.models[join].cache.on('updated', (record, diff) => {
if (diff[link.remote]) {
this.processRemoteJoinInserted({join, field, link, multi, record: record});
this.processRemoteJoinInserted({join, field, link, multi, record});
}
});
RocketChat.models[join].cache.on('removed', (record) => {
this.processRemoteJoinRemoved({join, field, link, multi, record: record});
this.processRemoteJoinRemoved({join, field, link, multi, record});
});
this.on('inserted', (localRecord) => {
this.processLocalJoinInserted({join, field, link, multi, localRecord: localRecord});
this.processLocalJoinInserted({join, field, link, multi, localRecord});
});
this.on('beforeupdate', (localRecord, diff) => {
@ -208,7 +208,7 @@ class ModelsBaseCache extends EventEmitter {
this.on('updated', (localRecord, diff) => {
if (diff[link.local]) {
this.processLocalJoinInserted({join, field, link, multi, localRecord: localRecord});
this.processLocalJoinInserted({join, field, link, multi, localRecord});
}
});
}
@ -307,8 +307,8 @@ class ModelsBaseCache extends EventEmitter {
}
this.indexes[fields.join(',')] = {
type: type,
fields: fields,
type,
fields,
data: {}
};
}

@ -317,9 +317,9 @@ class ModelsBaseDb extends EventEmitter {
action: 'update:query',
id: undefined,
data: {
query: query,
update: update,
options: options
query,
update,
options
},
oplog: false
});
@ -370,7 +370,7 @@ class ModelsBaseDb extends EventEmitter {
const _id = args[0]._id;
delete args[0]._id;
args.unshift({
_id: _id
_id
});
this.upsert(...args);

@ -50,7 +50,7 @@ RocketChat.registerAccessTokenService('google', function(options) {
}
return {
serviceData: serviceData,
serviceData,
options: {
profile: {
name: identity.name

@ -2,8 +2,8 @@ const AccessTokenServices = {};
RocketChat.registerAccessTokenService = function(serviceName, handleAccessTokenRequest) {
AccessTokenServices[serviceName] = {
serviceName: serviceName,
handleAccessTokenRequest: handleAccessTokenRequest
serviceName,
handleAccessTokenRequest
};
};

@ -26,7 +26,7 @@ this.CustomFields = (function() {
};
return {
init: init,
setCustomField: setCustomField
init,
setCustomField
};
}());

@ -1,17 +1,17 @@
/* globals LivechatVideoCall, Livechat */
// Functions to call on messages of type 'command'
this.Commands = {
survey: function() {
survey() {
if (!($('body #survey').length)) {
Blaze.render(Template.survey, $('body').get(0));
}
},
endCall: function() {
endCall() {
LivechatVideoCall.finish();
},
promptTranscript: function() {
promptTranscript() {
if (Livechat.transcript) {
const user = Meteor.user();
const email = user.visitorEmails && user.visitorEmails.length > 0 ? user.visitorEmails[0].address : '';
@ -62,7 +62,7 @@ this.Commands = {
}
},
connected: function() {
connected() {
Livechat.connecting = false;
}
};

@ -1,6 +1,6 @@
/* globals CustomFields, Livechat */
const api = {
pageVisited: function(info) {
pageVisited(info) {
if (info.change === 'url') {
Triggers.processRequest(info);
}
@ -8,11 +8,11 @@ const api = {
Meteor.call('livechat:pageVisited', visitor.getToken(), info);
},
setCustomField: function(key, value, overwrite = true) {
setCustomField(key, value, overwrite = true) {
CustomFields.setCustomField(visitor.getToken(), key, value, overwrite);
},
setTheme: function(theme) {
setTheme(theme) {
if (theme.color) {
Livechat.customColor = theme.color;
}
@ -21,19 +21,19 @@ const api = {
}
},
setDepartment: function(department) {
setDepartment(department) {
Livechat.department = department;
},
clearDepartment: function() {
clearDepartment() {
Livechat.department = null;
},
widgetOpened: function() {
widgetOpened() {
Livechat.setWidgetOpened();
},
widgetClosed: function() {
widgetClosed() {
Livechat.setWidgetClosed();
}
};

@ -88,10 +88,10 @@ this.Triggers = (function() {
};
return {
init: init,
processRequest: processRequest,
setTriggers: setTriggers,
setDisabled: setDisabled,
setEnabled: setEnabled
init,
processRequest,
setTriggers,
setDisabled,
setEnabled
};
}());

@ -86,14 +86,14 @@ Template.messages.helpers({
});
Template.messages.events({
'keyup .input-message': function(event, instance) {
'keyup .input-message'(event, instance) {
instance.chatMessages.keyup(visitor.getRoom(), event, instance);
instance.updateMessageInputHeight(event.currentTarget);
},
'keydown .input-message': function(event, instance) {
'keydown .input-message'(event, instance) {
return instance.chatMessages.keydown(visitor.getRoom(), event, instance);
},
'click .send-button': function(event, instance) {
'click .send-button'(event, instance) {
const input = instance.find('.input-message');
const sent = instance.chatMessages.send(visitor.getRoom(), input);
input.focus();
@ -101,17 +101,17 @@ Template.messages.events({
return sent;
},
'click .new-message': function(event, instance) {
'click .new-message'(event, instance) {
instance.atBottom = true;
return instance.find('.input-message').focus();
},
'click .error': function(event) {
'click .error'(event) {
return $(event.currentTarget).removeClass('show');
},
'click .toggle-options': function(event, instance) {
'click .toggle-options'(event, instance) {
instance.showOptions.set(!instance.showOptions.get());
},
'click .video-button': function(event) {
'click .video-button'(event) {
event.preventDefault();
if (!Meteor.userId()) {

@ -1,9 +1,9 @@
Template.survey.events({
'click button.skip': function(e, instance) {
'click button.skip'(e, instance) {
instance.$('#survey').remove();
},
'click button.send': function(e, instance) {
'click button.send'(e, instance) {
const formData = instance.$('form').serializeArray();
Meteor.call('livechat:saveSurveyFeedback', visitor.getToken(), visitor.getRoom(), formData, function(/*err, results*/) {
instance.$('#survey').remove();

@ -28,8 +28,8 @@ Template.livechatCustomFieldForm.events({
$btn.html(t('Saving'));
const customFieldData = {
field: field,
label: label,
field,
label,
scope: scope.trim(),
visibility: visibility.trim()
};

@ -50,7 +50,7 @@ Template.visitorInfo.helpers({
if (livechatData.hasOwnProperty(_id)) {
const customFields = Template.instance().customFields.get();
if (customFields) {
const field = _.findWhere(customFields, { _id: _id });
const field = _.findWhere(customFields, { _id });
if (field && field.visibility !== 'hidden') {
fields.push({ label: field.label, value: livechatData[_id] });
}

@ -23,7 +23,7 @@ RocketChat.API.v1.addRoute('livechat/department', { authRequired: true }, {
if (department) {
return RocketChat.API.v1.success({
department: department,
department,
agents: RocketChat.models.LivechatDepartmentAgents.find({ departmentId: department._id }).fetch()
});
}

@ -74,7 +74,7 @@ RocketChat.Livechat = {
}
// return messages;
return _.extend(RocketChat.sendMessage(guest, message, room), { newRoom: newRoom, showConnecting: this.showConnecting() });
return _.extend(RocketChat.sendMessage(guest, message, room), { newRoom, showConnecting: this.showConnecting() });
},
registerGuest({ token, name, email, department, phone, loginToken, username } = {}) {
check(token, String);
@ -84,7 +84,7 @@ RocketChat.Livechat = {
$set: {
profile: {
guest: true,
token: token
token
}
}
};
@ -119,9 +119,9 @@ RocketChat.Livechat = {
updateUser.$set.name = name;
const userData = {
username: username,
username,
globalRoles: ['livechat-guest'],
department: department,
department,
type: 'visitor',
joinDefaultChannels: false
};
@ -165,7 +165,7 @@ RocketChat.Livechat = {
const updateUser = {
$set: {
department: department
department
}
};

@ -4,7 +4,7 @@ RocketChat.QueueMethods = {
* default method where the agent with the least number
* of open chats is paired with the incoming livechat
*/
'Least_Amount' : function(guest, message, roomInfo) {
'Least_Amount'(guest, message, roomInfo) {
const agent = RocketChat.Livechat.getNextAgent(guest.department);
if (!agent) {
throw new Meteor.Error('no-agent-online', 'Sorry, no online agents');
@ -70,7 +70,7 @@ RocketChat.QueueMethods = {
* A room is still created with the initial message, but it is occupied by
* only the client until paired with an agent
*/
'Guest_Pool' : function(guest, message, roomInfo) {
'Guest_Pool'(guest, message, roomInfo) {
let agents = RocketChat.Livechat.getOnlineAgents(guest.department);
if (agents.count() === 0 && RocketChat.settings.get('Livechat_guest_pool_with_no_agents')) {

@ -15,8 +15,8 @@ Meteor.methods({
const language = (user && user.language) || RocketChat.settings.get('language') || 'en';
return RocketChat.Livechat.closeRoom({
user: user,
room: room,
user,
room,
comment: TAPi18n.__('Closed_by_visitor', { lng: language })
});
}

@ -13,9 +13,9 @@ Meteor.methods({
}
return RocketChat.Livechat.closeRoom({
user: user,
room: room,
comment: comment
user,
room,
comment
});
}
});

@ -1,13 +1,13 @@
Meteor.methods({
'livechat:registerGuest': function({ token, name, email, department } = {}) {
'livechat:registerGuest'({ token, name, email, department } = {}) {
const stampedToken = Accounts._generateStampedLoginToken();
const hashStampedToken = Accounts._hashStampedToken(stampedToken);
const userId = RocketChat.Livechat.registerGuest.call(this, {
token: token,
name: name,
email: email,
department: department,
token,
name,
email,
department,
loginToken: hashStampedToken
});
@ -15,7 +15,7 @@ Meteor.methods({
RocketChat.models.LivechatPageVisited.keepHistoryForToken(token);
return {
userId: userId,
userId,
token: stampedToken.token
};
}

@ -13,7 +13,7 @@ Meteor.methods({
RocketChat.models.Rooms.removeUsernameById(rid, username);
// find inquiry corresponding to room
const inquiry = RocketChat.models.LivechatInquiry.findOne({rid: rid});
const inquiry = RocketChat.models.LivechatInquiry.findOne({rid});
// mark inquiry as open
return RocketChat.models.LivechatInquiry.openInquiry(inquiry._id);

@ -1,7 +1,7 @@
/* eslint new-cap: [2, {"capIsNewExceptions": ["Match.ObjectIncluding", "Match.Optional"]}] */
Meteor.methods({
'livechat:saveInfo': function(guestData, roomData) {
'livechat:saveInfo'(guestData, roomData) {
if (!Meteor.userId() || !RocketChat.authz.hasPermission(Meteor.userId(), 'view-l-room')) {
throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'livechat:saveInfo' });
}

@ -1,5 +1,5 @@
Meteor.methods({
sendMessageLivechat: function(message) {
sendMessageLivechat(message) {
check(message.rid, String);
check(message.token, String);
@ -11,6 +11,6 @@ Meteor.methods({
}
});
return RocketChat.Livechat.sendMessage({ guest: guest, message: message });
return RocketChat.Livechat.sendMessage({ guest, message });
}
});

@ -1,8 +1,8 @@
Meteor.methods({
'livechat:setDepartmentForVisitor': function({ token, department } = {}) {
'livechat:setDepartmentForVisitor'({ token, department } = {}) {
RocketChat.Livechat.setDepartmentForGuest.call(this, {
token: token,
department: department
token,
department
});
// update visited page history to not expire

@ -8,22 +8,22 @@ class LivechatCustomField extends RocketChat.models._Base {
// FIND
findOneById(_id, options) {
const query = { _id: _id };
const query = { _id };
return this.findOne(query, options);
}
createOrUpdateCustomField(_id, field, label, scope, visibility, extraData) {
const record = {
label: label,
scope: scope,
visibility: visibility
label,
scope,
visibility
};
_.extend(record, extraData);
if (_id) {
this.update({ _id: _id }, { $set: record });
this.update({ _id }, { $set: record });
} else {
record._id = field;
_id = this.insert(record);
@ -34,7 +34,7 @@ class LivechatCustomField extends RocketChat.models._Base {
// REMOVE
removeById(_id) {
const query = { _id: _id };
const query = { _id };
return this.remove(query);
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save