New eslint rules (#14332)

* Fix new eslint rules

* Fix eslint rules:

no-unsafe-finally
no-await-in-loop

* More and more rules

* Fix changes after lint fixes

* Fix import orders

* New eslint rules

operator-linebreak
new-parens

* New eslint rule: no-useless-computed-key

* New eslint rule: no-useless-constructor

* Fix after develop merge

* Update lint package and fix new code
pull/14459/head
Diego Sampaio 7 years ago committed by GitHub
parent 4ba3513615
commit d53e264b83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      .scripts/fix-i18n.js
  2. 3
      .scripts/logs.js
  3. 7
      .scripts/md.js
  4. 3
      .scripts/set-version.js
  5. 7
      .scripts/start.js
  6. 3
      .scripts/version.js
  7. 3
      app/2fa/client/TOTPPassword.js
  8. 5
      app/2fa/client/accountSecurity.js
  9. 3
      app/2fa/server/lib/totp.js
  10. 3
      app/2fa/server/loginHandler.js
  11. 1
      app/2fa/server/methods/disable.js
  12. 1
      app/2fa/server/methods/enable.js
  13. 1
      app/2fa/server/methods/regenerateCodes.js
  14. 1
      app/2fa/server/methods/validateTempToken.js
  15. 2
      app/2fa/server/startup/settings.js
  16. 1
      app/action-links/both/lib/actionLinks.js
  17. 2
      app/action-links/client/init.js
  18. 1
      app/action-links/client/lib/actionLinks.js
  19. 1
      app/action-links/server/actionLinkHandler.js
  20. 1
      app/analytics/client/loadScript.js
  21. 3
      app/analytics/client/trackEvents.js
  22. 15
      app/api/server/api.js
  23. 1
      app/api/server/helpers/deprecationWarning.js
  24. 1
      app/api/server/helpers/getLoggedInUser.js
  25. 1
      app/api/server/helpers/getUserFromParams.js
  26. 1
      app/api/server/helpers/insertUserObject.js
  27. 8
      app/api/server/helpers/isUserFromParams.js
  28. 3
      app/api/server/helpers/parseJsonQuery.js
  29. 3
      app/api/server/index.js
  30. 5
      app/api/server/v1/assets.js
  31. 16
      app/api/server/v1/channels.js
  32. 9
      app/api/server/v1/chat.js
  33. 3
      app/api/server/v1/commands.js
  34. 5
      app/api/server/v1/e2e.js
  35. 4
      app/api/server/v1/emoji-custom.js
  36. 23
      app/api/server/v1/groups.js
  37. 13
      app/api/server/v1/im.js
  38. 3
      app/api/server/v1/import.js
  39. 5
      app/api/server/v1/integrations.js
  40. 3
      app/api/server/v1/misc.js
  41. 5
      app/api/server/v1/permissions.js
  42. 15
      app/api/server/v1/push.js
  43. 1
      app/api/server/v1/roles.js
  44. 9
      app/api/server/v1/rooms.js
  45. 7
      app/api/server/v1/settings.js
  46. 3
      app/api/server/v1/stats.js
  47. 5
      app/api/server/v1/subscriptions.js
  48. 11
      app/api/server/v1/users.js
  49. 1
      app/api/server/v1/video-conference.js
  50. 1
      app/apps/client/admin/appInstall.js
  51. 6
      app/apps/client/admin/appLogs.js
  52. 22
      app/apps/client/admin/appManage.js
  53. 1
      app/apps/client/admin/appWhatIsIt.js
  54. 1
      app/apps/client/admin/apps.js
  55. 2
      app/apps/client/admin/marketplace.js
  56. 1
      app/apps/client/admin/modalTemplates/iframeModal.js
  57. 1
      app/apps/client/communication/websockets.js
  58. 4
      app/apps/client/index.js
  59. 5
      app/apps/client/orchestrator.js
  60. 3
      app/apps/server/bridges/commands.js
  61. 4
      app/apps/server/bridges/environmental.js
  62. 8
      app/apps/server/bridges/listeners.js
  63. 1
      app/apps/server/bridges/messages.js
  64. 3
      app/apps/server/bridges/rooms.js
  65. 1
      app/apps/server/communication/methods.js
  66. 41
      app/apps/server/communication/rest.js
  67. 1
      app/apps/server/converters/messages.js
  68. 3
      app/apps/server/converters/rooms.js
  69. 3
      app/apps/server/converters/settings.js
  70. 3
      app/apps/server/converters/users.js
  71. 7
      app/apps/server/orchestrator.js
  72. 27
      app/apps/server/tests/messages.tests.js
  73. 1
      app/apps/server/tests/mocks/data/messages.data.js
  74. 44
      app/apps/server/tests/mocks/models/Messages.mock.js
  75. 24
      app/apps/server/tests/mocks/models/Users.mock.js
  76. 1
      app/apps/server/tests/mocks/orchestrator.mock.js
  77. 20
      app/assets/server/assets.js
  78. 4
      app/authorization/client/hasPermission.js
  79. 1
      app/authorization/client/route.js
  80. 4
      app/authorization/client/startup.js
  81. 1
      app/authorization/client/usersNameChanged.js
  82. 4
      app/authorization/client/views/permissions.js
  83. 11
      app/authorization/client/views/permissionsRole.js
  84. 5
      app/authorization/server/functions/addUserRoles.js
  85. 2
      app/authorization/server/functions/canAccessRoom.js
  86. 3
      app/authorization/server/functions/canSendMessage.js
  87. 1
      app/authorization/server/functions/getUsersInRole.js
  88. 5
      app/authorization/server/functions/removeUserFromRoles.js
  89. 1
      app/authorization/server/methods/addPermissionToRole.js
  90. 3
      app/authorization/server/methods/addUserToRole.js
  91. 1
      app/authorization/server/methods/deleteRole.js
  92. 1
      app/authorization/server/methods/removeRoleFromPermission.js
  93. 3
      app/authorization/server/methods/removeUserFromRole.js
  94. 1
      app/authorization/server/methods/saveRole.js
  95. 1
      app/authorization/server/publications/permissions.js
  96. 1
      app/authorization/server/publications/roles.js
  97. 1
      app/authorization/server/publications/usersInRole.js
  98. 141
      app/authorization/server/startup.js
  99. 3
      app/autolinker/client/client.js
  100. 1
      app/autolinker/server/settings.js
  101. Some files were not shown because too many files have changed in this diff Show More

@ -6,9 +6,10 @@
* - remove all keys not present in source i18n file
*/
const fg = require('fast-glob');
const fs = require('fs');
const fg = require('fast-glob');
const fixFiles = (path, source, newlineAtEnd = false) => {
const sourceFile = JSON.parse(fs.readFileSync(`${ path }${ source }`, 'utf8'));
const sourceKeys = Object.keys(sourceFile);

@ -1,5 +1,6 @@
const path = require('path');
const fs = require('fs');
const semver = require('semver');
const ProgressBar = require('progress');
const _ = require('underscore');
@ -14,7 +15,7 @@ const historyDataFile = path.join(__dirname, '../.github/history.json');
let historyData = (() => {
try {
return require(historyDataFile);
return require(historyDataFile); // eslint-disable-line import/no-dynamic-require
} catch (error) {
return {};
}

@ -1,8 +1,9 @@
const path = require('path');
const fs = require('fs');
const { execSync } = require('child_process');
const semver = require('semver');
const _ = require('underscore');
const { execSync } = require('child_process');
const historyDataFile = path.join(__dirname, '../.github/history.json');
const historyManualDataFile = path.join(__dirname, '../.github/history-manual.json');
@ -50,7 +51,7 @@ const SummaryNameEmoticons = {
const historyData = (() => {
try {
return require(historyDataFile);
return require(historyDataFile); // eslint-disable-line import/no-dynamic-require
} catch (error) {
return {};
}
@ -58,7 +59,7 @@ const historyData = (() => {
const historyManualData = (() => {
try {
return require(historyManualDataFile);
return require(historyManualDataFile); // eslint-disable-line import/no-dynamic-require
} catch (error) {
return {};
}

@ -2,6 +2,7 @@
const path = require('path');
const fs = require('fs');
const semver = require('semver');
const inquirer = require('inquirer');
// const execSync = require('child_process').execSync;
@ -10,7 +11,7 @@ const git = require('simple-git/promise')(process.cwd());
let pkgJson = {};
try {
pkgJson = require(path.resolve(
pkgJson = require(path.resolve( // eslint-disable-line import/no-dynamic-require
process.cwd(),
'./package.json'
));

@ -5,6 +5,7 @@ const fs = require('fs');
const extend = require('util')._extend;
const { spawn } = require('child_process');
const net = require('net');
const processes = [];
let exitCode;
@ -116,9 +117,9 @@ function startChimp() {
// params: ['2'],
options: {
env: Object.assign({}, process.env, {
NODE_PATH: `${ process.env.NODE_PATH +
path.delimiter + srcDir +
path.delimiter + srcDir }/node_modules`,
NODE_PATH: `${ process.env.NODE_PATH
+ path.delimiter + srcDir
+ path.delimiter + srcDir }/node_modules`,
}),
},
});

@ -1,8 +1,9 @@
const path = require('path');
let pkgJson = {};
try {
pkgJson = require(path.resolve(
pkgJson = require(path.resolve( // eslint-disable-line import/no-dynamic-require
process.cwd(),
'./package.json'
));

@ -1,8 +1,9 @@
import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';
import toastr from 'toastr';
import { modal } from '../../ui-utils';
import { t } from '../../utils';
import toastr from 'toastr';
function reportError(error, callback) {
if (callback) {

@ -1,11 +1,12 @@
import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import { Template } from 'meteor/templating';
import toastr from 'toastr';
import qrcode from 'yaqrcode';
import { modal } from '../../ui-utils';
import { settings } from '../../settings';
import { t } from '../../utils';
import toastr from 'toastr';
import qrcode from 'yaqrcode';
window.qrcode = qrcode;

@ -1,8 +1,9 @@
import { SHA256 } from 'meteor/sha';
import { Random } from 'meteor/random';
import speakeasy from 'speakeasy';
import { Users } from '../../../models';
import { settings } from '../../../settings';
import speakeasy from 'speakeasy';
export const TOTP = {
generateSecret() {

@ -1,8 +1,9 @@
import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';
import { TOTP } from './lib/totp';
import { settings } from '../../settings';
import { callbacks } from '../../callbacks';
import { TOTP } from './lib/totp';
Accounts.registerLoginHandler('totp', function(options) {
if (!options.totp || !options.totp.code) {

@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { Users } from '../../../models';
import { TOTP } from '../lib/totp';

@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { Users } from '../../../models';
import { TOTP } from '../lib/totp';

@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { Users } from '../../../models';
import { TOTP } from '../lib/totp';

@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { Users } from '../../../models';
import { TOTP } from '../lib/totp';

@ -17,5 +17,3 @@ settings.addGroup('Accounts', function() {
});
});
});

@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { Messages, Subscriptions } from '../../../models';
// Action Links namespace creation.

@ -1,12 +1,12 @@
import { Blaze } from 'meteor/blaze';
import { Template } from 'meteor/templating';
import { handleError } from '../../utils';
import { fireGlobalEvent, Layout } from '../../ui-utils';
import { messageArgs } from '../../ui-utils/client/lib/messageArgs';
import { actionLinks } from '../both/lib/actionLinks';
Template.room.events({
'click .action-link'(event, instance) {
event.preventDefault();

@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { handleError } from '../../../utils';
import { actionLinks } from '../../both/lib/actionLinks';
// Action Links Handler. This method will be called off the client.

@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { actionLinks } from '../both/lib/actionLinks';
// Action Links Handler. This method will be called off the client.

@ -1,6 +1,7 @@
import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';
import { Template } from 'meteor/templating';
import { settings } from '../../settings';
Template.body.onRendered(() => {

@ -1,9 +1,10 @@
import { Meteor } from 'meteor/meteor';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { Tracker } from 'meteor/tracker';
import { settings } from '../../settings';
import { callbacks } from '../../callbacks';
import { ChatRoom } from '../../models';
import { Tracker } from 'meteor/tracker';
function trackEvent(category, action, label) {
if (window._paq) {

@ -3,13 +3,14 @@ import { DDPCommon } from 'meteor/ddp-common';
import { DDP } from 'meteor/ddp';
import { Accounts } from 'meteor/accounts-base';
import { Restivus } from 'meteor/nimble:restivus';
import { RateLimiter } from 'meteor/rate-limit';
import _ from 'underscore';
import { Logger } from '../../logger';
import { settings } from '../../settings';
import { metrics } from '../../metrics';
import { hasPermission, hasAllPermission } from '../../authorization';
import { RateLimiter } from 'meteor/rate-limit';
import _ from 'underscore';
const logger = new Logger('API', {});
const rateLimiterDictionary = {};
@ -113,7 +114,7 @@ class APIClass extends Restivus {
statusCode: 404,
body: {
success: false,
error: msg ? msg : 'Resource not found',
error: msg || 'Resource not found',
},
};
}
@ -123,7 +124,7 @@ class APIClass extends Restivus {
statusCode: 403,
body: {
success: false,
error: msg ? msg : 'unauthorized',
error: msg || 'unauthorized',
},
};
}
@ -133,7 +134,7 @@ class APIClass extends Restivus {
statusCode: 429,
body: {
success: false,
error: msg ? msg : 'Too many requests',
error: msg || 'Too many requests',
},
};
}
@ -141,7 +142,7 @@ class APIClass extends Restivus {
reloadRoutesToRefreshRateLimiter() {
const { version } = this._config;
this._routes.forEach((route) => {
const shouldAddRateLimitToRoute = ((typeof route.options.rateLimiterOptions === 'object' || route.options.rateLimiterOptions === undefined) && Boolean(version) && !process.env.TEST_MODE && Boolean(defaultRateLimiterOptions.numRequestsAllowed && defaultRateLimiterOptions.intervalTimeInMS));
const shouldAddRateLimitToRoute = (typeof route.options.rateLimiterOptions === 'object' || route.options.rateLimiterOptions === undefined) && Boolean(version) && !process.env.TEST_MODE && Boolean(defaultRateLimiterOptions.numRequestsAllowed && defaultRateLimiterOptions.intervalTimeInMS);
if (shouldAddRateLimitToRoute) {
this.addRateLimiterRuleForRoutes({
routes: [route.path],
@ -204,7 +205,7 @@ class APIClass extends Restivus {
routes = [routes];
}
const { version } = this._config;
const shouldAddRateLimitToRoute = ((typeof options.rateLimiterOptions === 'object' || options.rateLimiterOptions === undefined) && Boolean(version) && !process.env.TEST_MODE && Boolean(defaultRateLimiterOptions.numRequestsAllowed && defaultRateLimiterOptions.intervalTimeInMS));
const shouldAddRateLimitToRoute = (typeof options.rateLimiterOptions === 'object' || options.rateLimiterOptions === undefined) && Boolean(version) && !process.env.TEST_MODE && Boolean(defaultRateLimiterOptions.numRequestsAllowed && defaultRateLimiterOptions.intervalTimeInMS);
if (shouldAddRateLimitToRoute) {
this.addRateLimiterRuleForRoutes({
routes,

@ -12,4 +12,3 @@ API.helperMethods.set('deprecationWarning', function _deprecationWarning({ endpo
return response;
});

@ -1,4 +1,5 @@
import { Accounts } from 'meteor/accounts-base';
import { Users } from '../../../models';
import { API } from '../api';

@ -1,5 +1,6 @@
// Convenience method, almost need to turn it into a middleware of sorts
import { Meteor } from 'meteor/meteor';
import { Users } from '../../../models';
import { API } from '../api';

@ -15,4 +15,3 @@ API.helperMethods.set('insertUserObject', function _addUserToObject({ object, us
return object;
});

@ -3,8 +3,8 @@ import { API } from '../api';
API.helperMethods.set('isUserFromParams', function _isUserFromParams() {
const params = this.requestParams();
return (!params.userId && !params.username && !params.user) ||
(params.userId && this.userId === params.userId) ||
(params.username && this.user.username === params.username) ||
(params.user && this.user.username === params.user);
return (!params.userId && !params.username && !params.user)
|| (params.userId && this.userId === params.userId)
|| (params.username && this.user.username === params.username)
|| (params.user && this.user.username === params.user);
});

@ -1,6 +1,7 @@
import { Meteor } from 'meteor/meteor';
import { hasPermission } from '../../../authorization';
import { EJSON } from 'meteor/ejson';
import { hasPermission } from '../../../authorization';
import { API } from '../api';
API.helperMethods.set('parseJsonQuery', function _parseJsonQuery() {

@ -1,5 +1,4 @@
import './settings';
export { API } from './api';
import './helpers/composeRoomWithLastMessage';
import './helpers/deprecationWarning';
import './helpers/getLoggedInUser';
@ -31,3 +30,5 @@ import './v1/stats';
import './v1/subscriptions';
import './v1/users';
import './v1/video-conference';
export { API } from './api';

@ -1,6 +1,7 @@
import { Meteor } from 'meteor/meteor';
import { RocketChatAssets } from '../../../assets';
import Busboy from 'busboy';
import { RocketChatAssets } from '../../../assets';
import { API } from '../api';
API.v1.addRoute('assets.setAsset', { authRequired: true }, {
@ -10,7 +11,7 @@ API.v1.addRoute('assets.setAsset', { authRequired: true }, {
let asset = {};
Meteor.wrapAsync((callback) => {
busboy.on('field', (fieldname, value) => fields[fieldname] = value);
busboy.on('field', (fieldname, value) => { fields[fieldname] = value; });
busboy.on('file', Meteor.bindEnvironment((fieldname, file, filename, encoding, mimetype) => {
const isValidAsset = Object.keys(RocketChatAssets.assets).includes(fieldname);
if (!isValidAsset) {

@ -1,9 +1,10 @@
import { Meteor } from 'meteor/meteor';
import _ from 'underscore';
import { Rooms, Subscriptions, Messages, Uploads, Integrations, Users } from '../../../models';
import { hasPermission } from '../../../authorization';
import { normalizeMessagesForUser } from '../../../utils/server/lib/normalizeMessagesForUser';
import { API } from '../api';
import _ from 'underscore';
// Returns the channel IF found otherwise it will return the failure of why it didn't. Check the `statusCode` property
function findChannelByIdOrName({ params, checkedArchived = true, userId }) {
@ -265,7 +266,7 @@ API.v1.addRoute('channels.files', { authRequired: true }, {
const ourQuery = Object.assign({}, query, { rid: findResult._id });
const files = Uploads.find(ourQuery, {
sort: sort ? sort : { name: 1 },
sort: sort || { name: 1 },
skip: offset,
limit: count,
fields,
@ -310,7 +311,7 @@ API.v1.addRoute('channels.getIntegrations', { authRequired: true }, {
ourQuery = Object.assign({}, query, ourQuery);
const integrations = Integrations.find(ourQuery, {
sort: sort ? sort : { _createdAt: 1 },
sort: sort || { _createdAt: 1 },
skip: offset,
limit: count,
fields,
@ -465,7 +466,7 @@ API.v1.addRoute('channels.list', { authRequired: true }, {
}
const cursor = Rooms.find(ourQuery, {
sort: sort ? sort : { name: 1 },
sort: sort || { name: 1 },
skip: offset,
limit: count,
fields,
@ -492,7 +493,7 @@ API.v1.addRoute('channels.list.joined', { authRequired: true }, {
// TODO: CACHE: Add Breacking notice since we removed the query param
const cursor = Rooms.findBySubscriptionTypeAndUserId('c', this.userId, {
sort: sort ? sort : { name: 1 },
sort: sort || { name: 1 },
skip: offset,
limit: count,
fields,
@ -569,7 +570,7 @@ API.v1.addRoute('channels.messages', { authRequired: true }, {
}
const cursor = Messages.find(ourQuery, {
sort: sort ? sort : { ts: -1 },
sort: sort || { ts: -1 },
skip: offset,
limit: count,
fields,
@ -934,7 +935,7 @@ API.v1.addRoute('channels.getAllUserMentionsByChannel', { authRequired: true },
const mentions = Meteor.runAsUser(this.userId, () => Meteor.call('getUserMentionsByChannel', {
roomId,
options: {
sort: sort ? sort : { ts: 1 },
sort: sort || { ts: 1 },
skip: offset,
limit: count,
},
@ -1005,4 +1006,3 @@ API.v1.addRoute('channels.removeLeader', { authRequired: true }, {
return API.v1.success();
},
});

@ -1,5 +1,6 @@
import { Meteor } from 'meteor/meteor';
import { Match, check } from 'meteor/check';
import { Messages } from '../../../models';
import { canAccessRoom, hasPermission } from '../../../authorization';
import { normalizeMessagesForUser } from '../../../utils/server/lib/normalizeMessagesForUser';
@ -111,7 +112,7 @@ API.v1.addRoute('chat.pinMessage', { authRequired: true }, {
}
let pinnedMessage;
Meteor.runAsUser(this.userId, () => pinnedMessage = Meteor.call('pinMessage', msg));
Meteor.runAsUser(this.userId, () => { pinnedMessage = Meteor.call('pinMessage', msg); });
const [message] = normalizeMessagesForUser([pinnedMessage], this.userId);
@ -153,7 +154,7 @@ API.v1.addRoute('chat.search', { authRequired: true }, {
}
let result;
Meteor.runAsUser(this.userId, () => result = Meteor.call('messageSearch', searchText, roomId, count).message.docs);
Meteor.runAsUser(this.userId, () => { result = Meteor.call('messageSearch', searchText, roomId, count).message.docs; });
return API.v1.success({
messages: normalizeMessagesForUser(result, this.userId),
@ -409,7 +410,7 @@ API.v1.addRoute('chat.getThreadsList', { authRequired: true }, {
}
const threadQuery = Object.assign({}, query, { rid, tcount: { $exists: true } });
const cursor = Messages.find(threadQuery, {
sort: sort ? sort : { ts: 1 },
sort: sort || { ts: 1 },
skip: offset,
limit: count,
fields,
@ -486,7 +487,7 @@ API.v1.addRoute('chat.getThreadMessages', { authRequired: true }, {
throw new Meteor.Error('error-not-allowed', 'Not Allowed');
}
const cursor = Messages.find({ ...query, tmid }, {
sort: sort ? sort : { ts: 1 },
sort: sort || { ts: 1 },
skip: offset,
limit: count,
fields,

@ -1,5 +1,6 @@
import { Meteor } from 'meteor/meteor';
import { Random } from 'meteor/random';
import { slashCommands } from '../../../utils';
import { Rooms } from '../../../models';
import { API } from '../api';
@ -35,7 +36,7 @@ API.v1.addRoute('commands.list', { authRequired: true }, {
const totalCount = commands.length;
commands = Rooms.processQueryOptionsOnResult(commands, {
sort: sort ? sort : { name: 1 },
sort: sort || { name: 1 },
skip: offset,
limit: count,
fields,

@ -1,10 +1,11 @@
import { Meteor } from 'meteor/meteor';
import { API } from '../api';
API.v1.addRoute('e2e.fetchMyKeys', { authRequired: true }, {
get() {
let result;
Meteor.runAsUser(this.userId, () => result = Meteor.call('e2e.fetchMyKeys'));
Meteor.runAsUser(this.userId, () => { result = Meteor.call('e2e.fetchMyKeys'); });
return API.v1.success(result);
},
@ -15,7 +16,7 @@ API.v1.addRoute('e2e.getUsersOfRoomWithoutKey', { authRequired: true }, {
const { rid } = this.queryParams;
let result;
Meteor.runAsUser(this.userId, () => result = Meteor.call('e2e.getUsersOfRoomWithoutKey', rid));
Meteor.runAsUser(this.userId, () => { result = Meteor.call('e2e.getUsersOfRoomWithoutKey', rid); });
return API.v1.success(result);
},

@ -1,7 +1,8 @@
import { Meteor } from 'meteor/meteor';
import Busboy from 'busboy';
import { EmojiCustom } from '../../../models';
import { API } from '../api';
import Busboy from 'busboy';
// DEPRECATED
// Will be removed after v1.12.0
@ -140,7 +141,6 @@ API.v1.addRoute('emoji-custom.update', { authRequired: true }, {
}));
this.request.pipe(busboy);
})();
});
},
});

@ -1,11 +1,9 @@
import _ from 'underscore';
import { Meteor } from 'meteor/meteor';
import { Subscriptions, Rooms, Messages, Uploads, Integrations, Users } from '../../../models/server';
import { hasPermission, canAccessRoom } from '../../../authorization/server';
import { normalizeMessagesForUser } from '../../../utils/server/lib/normalizeMessagesForUser';
import { API } from '../api';
// Returns the private group subscription IF found otherwise it will return the failure of why it didn't. Check the `statusCode` property
@ -24,9 +22,9 @@ function findPrivateGroupByIdOrName({ params, userId, checkedArchived = true })
archived: 1,
},
};
const room = params.roomId ?
Rooms.findOneById(params.roomId, roomOptions) :
Rooms.findOneByName(params.roomName, roomOptions);
const room = params.roomId
? Rooms.findOneById(params.roomId, roomOptions)
: Rooms.findOneByName(params.roomName, roomOptions);
if (!room || room.t !== 'p') {
throw new Meteor.Error('error-room-not-found', 'The required "roomId" or "roomName" param provided does not match any group');
@ -181,7 +179,7 @@ API.v1.addRoute('groups.counters', { authRequired: true }, {
const lm = room.lm ? room.lm : room._updatedAt;
if (typeof subscription !== 'undefined' && subscription.open) {
unreads = Messages.countVisibleByRoomIdBetweenTimestampsInclusive(subscription.rid, (subscription.ls || subscription.ts), lm);
unreads = Messages.countVisibleByRoomIdBetweenTimestampsInclusive(subscription.rid, subscription.ls || subscription.ts, lm);
unreadsFrom = subscription.ls || subscription.ts;
userMentions = subscription.userMentions;
joined = true;
@ -265,7 +263,7 @@ API.v1.addRoute('groups.files', { authRequired: true }, {
const ourQuery = Object.assign({}, query, { rid: findResult.rid });
const files = Uploads.find(ourQuery, {
sort: sort ? sort : { name: 1 },
sort: sort || { name: 1 },
skip: offset,
limit: count,
fields,
@ -303,7 +301,7 @@ API.v1.addRoute('groups.getIntegrations', { authRequired: true }, {
const ourQuery = Object.assign({}, query, { channel: { $in: channelsToSearch } });
const integrations = Integrations.find(ourQuery, {
sort: sort ? sort : { _createdAt: 1 },
sort: sort || { _createdAt: 1 },
skip: offset,
limit: count,
fields,
@ -427,7 +425,7 @@ API.v1.addRoute('groups.list', { authRequired: true }, {
// TODO: CACHE: Add Breacking notice since we removed the query param
const cursor = Rooms.findBySubscriptionTypeAndUserId('p', this.userId, {
sort: sort ? sort : { name: 1 },
sort: sort || { name: 1 },
skip: offset,
limit: count,
fields,
@ -460,7 +458,7 @@ API.v1.addRoute('groups.listAll', { authRequired: true }, {
const totalCount = rooms.length;
rooms = Rooms.processQueryOptionsOnResult(rooms, {
sort: sort ? sort : { name: 1 },
sort: sort || { name: 1 },
skip: offset,
limit: count,
fields,
@ -500,7 +498,7 @@ API.v1.addRoute('groups.members', { authRequired: true }, {
const users = Users.find({ _id: { $in: members } }, {
fields: { _id: 1, username: 1, name: 1, status: 1, utcOffset: 1 },
sort: { username: sort.username != null ? sort.username : 1 },
sort: { username: sort.username != null ? sort.username : 1 },
}).fetch();
return API.v1.success({
@ -521,7 +519,7 @@ API.v1.addRoute('groups.messages', { authRequired: true }, {
const ourQuery = Object.assign({}, query, { rid: findResult.rid });
const messages = Messages.find(ourQuery, {
sort: sort ? sort : { ts: -1 },
sort: sort || { ts: -1 },
skip: offset,
limit: count,
fields,
@ -815,4 +813,3 @@ API.v1.addRoute('groups.moderators', { authRequired: true }, {
});
},
});

@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { getRoomByNameOrIdWithOptionToJoin } from '../../../lib';
import { Subscriptions, Uploads, Users, Messages, Rooms } from '../../../models';
import { hasPermission } from '../../../authorization';
@ -124,7 +125,7 @@ API.v1.addRoute(['dm.files', 'im.files'], { authRequired: true }, {
const ourQuery = Object.assign({}, query, { rid: findResult.room._id });
const files = Uploads.find(ourQuery, {
sort: sort ? sort : { name: 1 },
sort: sort || { name: 1 },
skip: offset,
limit: count,
fields,
@ -195,7 +196,7 @@ API.v1.addRoute(['dm.members', 'im.members'], { authRequired: true }, {
const { offset, count } = this.getPaginationItems();
const { sort } = this.parseJsonQuery();
const cursor = Subscriptions.findByRoomId(findResult.room._id, {
sort: { 'u.username': sort && sort.username ? sort.username : 1 },
sort: { 'u.username': sort && sort.username ? sort.username : 1 },
skip: offset,
limit: count,
});
@ -205,7 +206,7 @@ API.v1.addRoute(['dm.members', 'im.members'], { authRequired: true }, {
const users = Users.find({ username: { $in: members } }, {
fields: { _id: 1, username: 1, name: 1, status: 1, utcOffset: 1 },
sort: { username: sort && sort.username ? sort.username : 1 },
sort: { username: sort && sort.username ? sort.username : 1 },
}).fetch();
return API.v1.success({
@ -227,7 +228,7 @@ API.v1.addRoute(['dm.messages', 'im.messages'], { authRequired: true }, {
const ourQuery = Object.assign({}, query, { rid: findResult.room._id });
const messages = Messages.find(ourQuery, {
sort: sort ? sort : { ts: -1 },
sort: sort || { ts: -1 },
skip: offset,
limit: count,
fields,
@ -267,7 +268,7 @@ API.v1.addRoute(['dm.messages.others', 'im.messages.others'], { authRequired: tr
const ourQuery = Object.assign({}, query, { rid: room._id });
const msgs = Messages.find(ourQuery, {
sort: sort ? sort : { ts: -1 },
sort: sort || { ts: -1 },
skip: offset,
limit: count,
fields,
@ -320,7 +321,7 @@ API.v1.addRoute(['dm.list.everyone', 'im.list.everyone'], { authRequired: true }
const ourQuery = Object.assign({}, query, { t: 'd' });
const rooms = Rooms.find(ourQuery, {
sort: sort ? sort : { name: 1 },
sort: sort || { name: 1 },
skip: offset,
limit: count,
fields,

@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { API } from '../api';
API.v1.addRoute('uploadImportFile', { authRequired: true }, {
@ -43,7 +44,7 @@ API.v1.addRoute('getImportFileData', { authRequired: true }, {
API.v1.addRoute('getLatestImportOperations', { authRequired: true }, {
get() {
let result;
Meteor.runAsUser(this.userId, () => result = Meteor.call('getLatestImportOperations'));
Meteor.runAsUser(this.userId, () => { result = Meteor.call('getLatestImportOperations'); });
return API.v1.success(result);
},

@ -1,5 +1,6 @@
import { Meteor } from 'meteor/meteor';
import { Match, check } from 'meteor/check';
import { hasPermission } from '../../../authorization';
import { IntegrationHistory, Integrations } from '../../../models';
import { API } from '../api';
@ -61,7 +62,7 @@ API.v1.addRoute('integrations.history', { authRequired: true }, {
const ourQuery = Object.assign({}, query, { 'integration._id': id });
const history = IntegrationHistory.find(ourQuery, {
sort: sort ? sort : { _updatedAt: -1 },
sort: sort || { _updatedAt: -1 },
skip: offset,
limit: count,
fields,
@ -87,7 +88,7 @@ API.v1.addRoute('integrations.list', { authRequired: true }, {
const ourQuery = Object.assign({}, query);
const integrations = Integrations.find(ourQuery, {
sort: sort ? sort : { ts: -1 },
sort: sort || { ts: -1 },
skip: offset,
limit: count,
fields,

@ -1,13 +1,14 @@
import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import { TAPi18n } from 'meteor/tap:i18n';
import s from 'underscore.string';
import { hasRole } from '../../../authorization';
import { Info } from '../../../utils';
import { Users } from '../../../models';
import { settings } from '../../../settings';
import { API } from '../api';
import s from 'underscore.string';
// DEPRECATED
// Will be removed after v1.12.0

@ -1,5 +1,6 @@
import { Meteor } from 'meteor/meteor';
import { Match, check } from 'meteor/check';
import { hasPermission } from '../../../authorization';
import { Permissions, Roles } from '../../../models';
import { API } from '../api';
@ -52,7 +53,7 @@ API.v1.addRoute('permissions.listAll', { authRequired: true }, {
}
let result;
Meteor.runAsUser(this.userId, () => result = Meteor.call('permissions/get', updatedSinceDate));
Meteor.runAsUser(this.userId, () => { result = Meteor.call('permissions/get', updatedSinceDate); });
if (Array.isArray(result)) {
result = {
@ -100,7 +101,7 @@ API.v1.addRoute('permissions.update', { authRequired: true }, {
if (permissionNotFound) {
return API.v1.failure('Invalid permission', 'error-invalid-permission');
} else if (roleNotFound) {
} if (roleNotFound) {
return API.v1.failure('Invalid role', 'error-invalid-role');
}

@ -1,6 +1,7 @@
import { Meteor } from 'meteor/meteor';
import { Random } from 'meteor/random';
import { Push } from 'meteor/rocketchat:push';
import { API } from '../api';
API.v1.addRoute('push.token', { authRequired: true }, {
@ -28,12 +29,14 @@ API.v1.addRoute('push.token', { authRequired: true }, {
let result;
Meteor.runAsUser(this.userId, () => result = Meteor.call('raix:push-update', {
id,
token: { [type]: value },
appName,
userId: this.userId,
}));
Meteor.runAsUser(this.userId, () => {
result = Meteor.call('raix:push-update', {
id,
token: { [type]: value },
appName,
userId: this.userId,
});
});
return API.v1.success({ result });
},

@ -1,5 +1,6 @@
import { Meteor } from 'meteor/meteor';
import { Match, check } from 'meteor/check';
import { Roles } from '../../../models';
import { API } from '../api';

@ -1,7 +1,8 @@
import { Meteor } from 'meteor/meteor';
import Busboy from 'busboy';
import { FileUpload } from '../../../file-upload';
import { Rooms } from '../../../models';
import Busboy from 'busboy';
import { API } from '../api';
function findRoomByIdOrName({ params, checkedArchived = true }) {
@ -41,7 +42,7 @@ API.v1.addRoute('rooms.get', { authRequired: true }, {
}
let result;
Meteor.runAsUser(this.userId, () => result = Meteor.call('rooms/get', updatedSinceDate));
Meteor.runAsUser(this.userId, () => { result = Meteor.call('rooms/get', updatedSinceDate); });
if (Array.isArray(result)) {
result = {
@ -83,7 +84,7 @@ API.v1.addRoute('rooms.upload/:rid', { authRequired: true }, {
});
});
busboy.on('field', (fieldname, value) => fields[fieldname] = value);
busboy.on('field', (fieldname, value) => { fields[fieldname] = value; });
busboy.on('finish', Meteor.bindEnvironment(() => callback()));
@ -255,7 +256,7 @@ API.v1.addRoute('rooms.getDiscussions', { authRequired: true }, {
const ourQuery = Object.assign(query, { prid: room._id });
const discussions = Rooms.find(ourQuery, {
sort: sort ? sort : { fname: 1 },
sort: sort || { fname: 1 },
skip: offset,
limit: count,
fields,

@ -1,10 +1,11 @@
import { Meteor } from 'meteor/meteor';
import { Match, check } from 'meteor/check';
import { ServiceConfiguration } from 'meteor/service-configuration';
import _ from 'underscore';
import { Settings } from '../../../models';
import { hasPermission } from '../../../authorization';
import { API } from '../api';
import _ from 'underscore';
// settings endpoints
API.v1.addRoute('settings.public', { authRequired: false }, {
@ -20,7 +21,7 @@ API.v1.addRoute('settings.public', { authRequired: false }, {
ourQuery = Object.assign({}, query, ourQuery);
const settings = Settings.find(ourQuery, {
sort: sort ? sort : { _id: 1 },
sort: sort || { _id: 1 },
skip: offset,
limit: count,
fields: Object.assign({ _id: 1, value: 1 }, fields),
@ -79,7 +80,7 @@ API.v1.addRoute('settings', { authRequired: true }, {
ourQuery = Object.assign({}, query, ourQuery);
const settings = Settings.find(ourQuery, {
sort: sort ? sort : { _id: 1 },
sort: sort || { _id: 1 },
skip: offset,
limit: count,
fields: Object.assign({ _id: 1, value: 1 }, fields),

@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { hasPermission } from '../../../authorization';
import { Statistics } from '../../../models';
import { API } from '../api';
@ -31,7 +32,7 @@ API.v1.addRoute('statistics.list', { authRequired: true }, {
const { sort, fields, query } = this.parseJsonQuery();
const statistics = Statistics.find(query, {
sort: sort ? sort : { name: 1 },
sort: sort || { name: 1 },
skip: offset,
limit: count,
fields,

@ -1,5 +1,6 @@
import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import { Subscriptions } from '../../../models';
import { API } from '../api';
@ -17,7 +18,7 @@ API.v1.addRoute('subscriptions.get', { authRequired: true }, {
}
let result;
Meteor.runAsUser(this.userId, () => result = Meteor.call('subscriptions/get', updatedSinceDate));
Meteor.runAsUser(this.userId, () => { result = Meteor.call('subscriptions/get', updatedSinceDate); });
if (Array.isArray(result)) {
result = {
@ -82,5 +83,3 @@ API.v1.addRoute('subscriptions.unread', { authRequired: true }, {
return API.v1.success();
},
});

@ -1,6 +1,9 @@
import { Meteor } from 'meteor/meteor';
import { Match, check } from 'meteor/check';
import { TAPi18n } from 'meteor/tap:i18n';
import _ from 'underscore';
import Busboy from 'busboy';
import { Users, Subscriptions } from '../../../models';
import { hasPermission } from '../../../authorization';
import { settings } from '../../../settings';
@ -14,8 +17,6 @@ import {
saveCustomFields,
} from '../../../lib';
import { API } from '../api';
import _ from 'underscore';
import Busboy from 'busboy';
API.v1.addRoute('users.create', { authRequired: true }, {
post() {
@ -122,7 +123,6 @@ API.v1.addRoute('users.setActiveStatus', { authRequired: true }, {
Meteor.call('setUserActiveStatus', this.bodyParams.userId, this.bodyParams.activeStatus);
});
return API.v1.success({ user: Users.findOneById(this.bodyParams.userId, { fields: { active: 1 } }) });
},
});
@ -191,7 +191,7 @@ API.v1.addRoute('users.list', { authRequired: true }, {
const { sort, fields, query } = this.parseJsonQuery();
const users = Users.find(query, {
sort: sort ? sort : { username: 1 },
sort: sort || { username: 1 },
skip: offset,
limit: count,
fields,
@ -409,9 +409,8 @@ API.v1.addRoute('users.getPreferences', { authRequired: true }, {
return API.v1.success({
preferences,
});
} else {
return API.v1.failure(TAPi18n.__('Accounts_Default_User_Preferences_not_available').toUpperCase());
}
return API.v1.failure(TAPi18n.__('Accounts_Default_User_Preferences_not_available').toUpperCase());
},
});

@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { Rooms } from '../../../models';
import { API } from '../api';

@ -11,6 +11,7 @@ import { ReactiveVar } from 'meteor/reactive-var';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { Template } from 'meteor/templating';
import { Tracker } from 'meteor/tracker';
import { APIClient } from '../../../utils';
import { SideNav } from '../../../ui-utils/client';

@ -3,9 +3,10 @@ import { FlowRouter } from 'meteor/kadira:flow-router';
import { Template } from 'meteor/templating';
import { TAPi18n } from 'meteor/tap:i18n';
import { Tracker } from 'meteor/tracker';
import { APIClient } from '../../../utils';
import moment from 'moment';
import hljs from 'highlight.js';
import { APIClient } from '../../../utils';
import { SideNav } from '../../../ui-utils/client';
const loadData = (instance) => {
@ -13,7 +14,6 @@ const loadData = (instance) => {
APIClient.get(`apps/${ instance.id.get() }`),
APIClient.get(`apps/${ instance.id.get() }/logs`),
]).then((results) => {
instance.app.set(results[0].app);
instance.logs.set(results[1].logs);
@ -72,7 +72,7 @@ Template.appLogs.helpers({
if (!data) {
return value;
} else if (typeof data === 'object') {
} if (typeof data === 'object') {
value = hljs.highlight('json', JSON.stringify(data, null, 2)).value;
} else {
value = hljs.highlight('json', data).value;

@ -4,19 +4,18 @@ import { FlowRouter } from 'meteor/kadira:flow-router';
import { Template } from 'meteor/templating';
import { TAPi18n, TAPi18next } from 'meteor/tap:i18n';
import { Tracker } from 'meteor/tracker';
import _ from 'underscore';
import s from 'underscore.string';
import toastr from 'toastr';
import semver from 'semver';
import { isEmail, APIClient } from '../../../utils';
import { settings } from '../../../settings';
import { Markdown } from '../../../markdown/client';
import { modal } from '../../../ui-utils';
import _ from 'underscore';
import s from 'underscore.string';
import toastr from 'toastr';
import { AppEvents } from '../communication';
import { Utilities } from '../../lib/misc/Utilities';
import { Apps } from '../orchestrator';
import semver from 'semver';
import { SideNav } from '../../../ui-utils/client';
function getApps(instance) {
@ -194,7 +193,7 @@ Template.apps.onDestroyed(function() {
Template.appManage.helpers({
isEmail,
_(key, ...args) {
const options = (args.pop()).hash;
const options = args.pop().hash;
if (!_.isEmpty(args)) {
options.sprintf = args;
}
@ -300,7 +299,7 @@ Template.appManage.helpers({
parseDescription(i18nDescription) {
const item = Markdown.parseMessageNotEscaped({ html: Template.instance().__(i18nDescription) });
item.tokens.forEach((t) => item.html = item.html.replace(t.token, t.text));
item.tokens.forEach((t) => { item.html = item.html.replace(t.token, t.text); });
return item.html;
},
@ -434,25 +433,24 @@ Template.appManage.events({
});
if (toSave.length === 0) {
throw 'Nothing to save..';
throw new Error('Nothing to save..');
}
const result = await APIClient.post(`apps/${ t.id.get() }/settings`, undefined, { settings: toSave });
console.log('Updating results:', result);
result.updated.forEach((setting) => {
settings[setting.id].value = settings[setting.id].oldValue = setting.value;
settings[setting.id].value = setting.value;
settings[setting.id].oldValue = setting.value;
});
Object.keys(settings).forEach((k) => {
const setting = settings[k];
setting.hasChanged = false;
});
t.settings.set(settings);
} catch (e) {
console.log(e);
} finally {
t.loading.set(false);
}
},
'change input[type="checkbox"]': (e, t) => {
@ -470,7 +468,7 @@ Template.appManage.events({
}
},
'change .rc-select__element' : (e, t) => {
'change .rc-select__element': (e, t) => {
const labelFor = $(e.currentTarget).attr('name');
const value = $(e.currentTarget).val();

@ -3,6 +3,7 @@ import { ReactiveVar } from 'meteor/reactive-var';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { Template } from 'meteor/templating';
import { Tracker } from 'meteor/tracker';
import { Apps } from '../orchestrator';
import { SideNav } from '../../../ui-utils/client';

@ -3,6 +3,7 @@ import { ReactiveVar } from 'meteor/reactive-var';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { Template } from 'meteor/templating';
import { Tracker } from 'meteor/tracker';
import { settings } from '../../../settings';
import { t, APIClient } from '../../../utils';
import { AppEvents } from '../communication';

@ -4,6 +4,7 @@ import { ReactiveVar } from 'meteor/reactive-var';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { Template } from 'meteor/templating';
import { Tracker } from 'meteor/tracker';
import { settings } from '../../../settings';
import { t, APIClient } from '../../../utils';
import { modal } from '../../../ui-utils';
@ -287,7 +288,6 @@ Template.marketplace.events({
if (confirmed) {
FlowRouter.go('/admin/cloud');
}
return;
});
return;
}

@ -1,4 +1,5 @@
import { Template } from 'meteor/templating';
import { modal } from '../../../../ui-utils';
Template.iframeModal.onCreated(function() {

@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { slashCommands, APIClient } from '../../../utils';
import { CachedCollectionManager } from '../../../ui-cached-collection';

@ -1,5 +1,3 @@
export { Apps } from './orchestrator';
import './admin/modalTemplates/iframeModal.html';
import './admin/modalTemplates/iframeModal';
import './admin/marketplace.html';
@ -14,3 +12,5 @@ import './admin/appManage.html';
import './admin/appManage';
import './admin/appWhatIsIt.html';
import './admin/appWhatIsIt';
export { Apps } from './orchestrator';

@ -1,9 +1,10 @@
import { Meteor } from 'meteor/meteor';
import { AppWebsocketReceiver } from './communication';
import { Utilities } from '../lib/misc/Utilities';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { BlazeLayout } from 'meteor/kadira:blaze-layout';
import { TAPi18next } from 'meteor/tap:i18n';
import { AppWebsocketReceiver } from './communication';
import { Utilities } from '../lib/misc/Utilities';
import { APIClient } from '../../utils';
import { AdminBox } from '../../ui-utils';
import { CachedCollectionManager } from '../../ui-cached-collection';

@ -1,6 +1,7 @@
import { Meteor } from 'meteor/meteor';
import { slashCommands } from '../../../utils';
import { SlashCommandContext } from '@rocket.chat/apps-engine/definition/slashcommands';
import { slashCommands } from '../../../utils';
import { Utilities } from '../../lib/misc/Utilities';
export class AppCommandsBridge {

@ -7,7 +7,7 @@ export class AppEnvironmentalVariableBridge {
async getValueByName(envVarName, appId) {
this.orch.debugLog(`The App ${ appId } is getting the environmental variable value ${ envVarName }.`);
if (!(await this.isReadable(envVarName, appId))) {
if (!await this.isReadable(envVarName, appId)) {
throw new Error(`The environmental variable "${ envVarName }" is not readable.`);
}
@ -23,7 +23,7 @@ export class AppEnvironmentalVariableBridge {
async isSet(envVarName, appId) {
this.orch.debugLog(`The App ${ appId } is checking if the environmental variable is set ${ envVarName }.`);
if (!(await this.isReadable(envVarName, appId))) {
if (!await this.isReadable(envVarName, appId)) {
throw new Error(`The environmental variable "${ envVarName }" is not readable.`);
}

@ -9,9 +9,9 @@ export class AppListenerBridge {
if (typeof result === 'boolean') {
return result;
} else {
return this.orch.getConverters().get('messages').convertAppMessage(result);
}
return this.orch.getConverters().get('messages').convertAppMessage(result);
// try {
// } catch (e) {
@ -26,9 +26,9 @@ export class AppListenerBridge {
if (typeof result === 'boolean') {
return result;
} else {
return this.orch.getConverters().get('rooms').convertAppRoom(result);
}
return this.orch.getConverters().get('rooms').convertAppRoom(result);
// try {
// } catch (e) {

@ -1,5 +1,6 @@
import { Meteor } from 'meteor/meteor';
import { Random } from 'meteor/random';
import { Messages, Users, Subscriptions } from '../../../models';
import { Notifications } from '../../../notifications';
import { updateMessage } from '../../../lib/server/functions/updateMessage';

@ -1,6 +1,7 @@
import { Meteor } from 'meteor/meteor';
import { Rooms, Subscriptions, Users } from '../../../models';
import { RoomType } from '@rocket.chat/apps-engine/definition/rooms';
import { Rooms, Subscriptions, Users } from '../../../models';
import { addUserToRoom } from '../../../lib/server/functions/addUserToRoom';
export class AppRoomBridge {

@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { settings } from '../../../settings';
import { hasPermission } from '../../../authorization';

@ -1,8 +1,8 @@
import { Meteor } from 'meteor/meteor';
import { HTTP } from 'meteor/http';
import { API } from '../../../api/server';
import Busboy from 'busboy';
import { API } from '../../../api/server';
import { getWorkspaceAccessToken, getUserCloudAccessToken } from '../../../cloud/server';
import { settings } from '../../../settings';
import { Info } from '../../../utils';
@ -238,9 +238,8 @@ export class AppsRestApi {
info.status = prl.getStatus();
return API.v1.success({ app: info });
} else {
return API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
}
return API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
},
post() {
// TODO: Verify permissions
@ -320,9 +319,8 @@ export class AppsRestApi {
info.status = prl.getStatus();
return API.v1.success({ app: info });
} else {
return API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
}
return API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
},
});
@ -334,9 +332,8 @@ export class AppsRestApi {
const info = prl.getInfo();
return API.v1.success({ iconFileContent: info.iconFileContent });
} else {
return API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
}
return API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
},
});
@ -348,9 +345,8 @@ export class AppsRestApi {
const languages = prl.getStorageItem().languageContent || {};
return API.v1.success({ languages });
} else {
return API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
}
return API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
},
});
@ -364,7 +360,7 @@ export class AppsRestApi {
const ourQuery = Object.assign({}, query, { appId: prl.getID() });
const options = {
sort: sort ? sort : { _updatedAt: -1 },
sort: sort || { _updatedAt: -1 },
skip: offset,
limit: count,
fields,
@ -373,9 +369,8 @@ export class AppsRestApi {
const logs = Promise.await(orchestrator.getLogStorage().find(ourQuery, options));
return API.v1.success({ logs });
} else {
return API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
}
return API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
},
});
@ -393,9 +388,8 @@ export class AppsRestApi {
});
return API.v1.success({ settings });
} else {
return API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
}
return API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
},
post() {
if (!this.bodyParams || !this.bodyParams.settings) {
@ -432,11 +426,10 @@ export class AppsRestApi {
} catch (e) {
if (e.message.includes('No setting found')) {
return API.v1.notFound(`No Setting found on the App by the id of: "${ this.urlParams.settingId }"`);
} else if (e.message.includes('No App found')) {
} if (e.message.includes('No App found')) {
return API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
} else {
return API.v1.failure(e.message);
}
return API.v1.failure(e.message);
}
},
post() {
@ -451,11 +444,10 @@ export class AppsRestApi {
} catch (e) {
if (e.message.includes('No setting found')) {
return API.v1.notFound(`No Setting found on the App by the id of: "${ this.urlParams.settingId }"`);
} else if (e.message.includes('No App found')) {
} if (e.message.includes('No App found')) {
return API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
} else {
return API.v1.failure(e.message);
}
return API.v1.failure(e.message);
}
},
});
@ -468,9 +460,8 @@ export class AppsRestApi {
return API.v1.success({
apis: manager.apiManager.listApis(this.urlParams.id),
});
} else {
return API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
}
return API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
},
});
@ -480,9 +471,8 @@ export class AppsRestApi {
if (prl) {
return API.v1.success({ status: prl.getStatus() });
} else {
return API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
}
return API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
},
post() {
if (!this.bodyParams.status || typeof this.bodyParams.status !== 'string') {
@ -495,9 +485,8 @@ export class AppsRestApi {
const result = Promise.await(manager.changeStatus(prl.getID(), this.bodyParams.status));
return API.v1.success({ status: result.getStatus() });
} else {
return API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
}
return API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
},
});
}

@ -1,4 +1,5 @@
import { Random } from 'meteor/random';
import { Messages, Rooms, Users } from '../../../models';
import { transformMappedData } from '../../lib/misc/transformMappedData';

@ -1,6 +1,7 @@
import { Rooms, Users } from '../../../models';
import { RoomType } from '@rocket.chat/apps-engine/definition/rooms';
import { Rooms, Users } from '../../../models';
export class AppRoomsConverter {
constructor(orch) {
this.orch = orch;

@ -1,6 +1,7 @@
import { Settings } from '../../../models';
import { SettingType } from '@rocket.chat/apps-engine/definition/settings';
import { Settings } from '../../../models';
export class AppSettingsConverter {
constructor(orch) {
this.orch = orch;

@ -1,6 +1,7 @@
import { Users } from '../../../models';
import { UserStatusConnection, UserType } from '@rocket.chat/apps-engine/definition/users';
import { Users } from '../../../models';
export class AppUsersConverter {
constructor(orch) {
this.orch = orch;

@ -1,11 +1,12 @@
import { Meteor } from 'meteor/meteor';
import { Permissions, AppsLogsModel, AppsModel, AppsPersistenceModel } from '../../models';
import { settings } from '../../settings';
import { AppManager } from '@rocket.chat/apps-engine/server/AppManager';
import { RealAppBridges } from './bridges';
import { AppMethods, AppsRestApi, AppServerNotifier } from './communication';
import { AppMessagesConverter, AppRoomsConverter, AppSettingsConverter, AppUsersConverter } from './converters';
import { AppRealStorage, AppRealLogsStorage } from './storage';
import { AppManager } from '@rocket.chat/apps-engine/server/AppManager';
import { settings } from '../../settings';
import { Permissions, AppsLogsModel, AppsModel, AppsPersistenceModel } from '../../models';
export let Apps;

@ -10,6 +10,7 @@ import { RoomsMock } from './mocks/models/Rooms.mock';
import { UsersMock } from './mocks/models/Users.mock';
chai.use(require('chai-datetime'));
const { expect } = chai;
mock('../../../models', './mocks/models');
@ -52,7 +53,6 @@ describe('The AppMessagesConverter instance', function() {
const updatedAt = new Date('2019-03-30T01:22:08.412Z');
describe('when converting a message from Rocket.Chat to the Engine schema', function() {
it('should return `undefined` when `msgObj` is falsy', function() {
const appMessage = messagesConverter.convertMessage(undefined);
@ -84,17 +84,17 @@ describe('The AppMessagesConverter instance', function() {
messagesConverter.convertMessage(rocketchatMessageMock);
expect(rocketchatMessageMock).to.deep.equal({
_id : 'SimpleMessageMock',
t : 'uj',
rid : 'GENERAL',
ts : new Date('2019-03-30T01:22:08.389Z'),
msg : 'rocket.cat',
u : {
_id : 'rocket.cat',
username : 'rocket.cat',
_id: 'SimpleMessageMock',
t: 'uj',
rid: 'GENERAL',
ts: new Date('2019-03-30T01:22:08.389Z'),
msg: 'rocket.cat',
u: {
_id: 'rocket.cat',
username: 'rocket.cat',
},
groupable : false,
_updatedAt : new Date('2019-03-30T01:22:08.412Z'),
groupable: false,
_updatedAt: new Date('2019-03-30T01:22:08.412Z'),
});
});
@ -110,15 +110,14 @@ describe('The AppMessagesConverter instance', function() {
const appMessage = messagesConverter.convertMessage(messagesMock.findOneById('LivechatGuestMessageMock'));
expect(appMessage).to.have.property('sender').which.includes({
id : 'guest1234',
id: 'guest1234',
username: 'guest1234',
name : 'Livechat Guest',
name: 'Livechat Guest',
});
});
});
describe('when converting a message from the Engine schema back to Rocket.Chat', function() {
it('should return `undefined` when `message` is falsy', function() {
const rocketchatMessage = messagesConverter.convertAppMessage(undefined);

@ -113,4 +113,3 @@ export const appMessageInvalidRoomMock = {
t: 'uj',
},
};

@ -3,34 +3,34 @@ import { BaseModelMock } from './BaseModel.mock';
export class MessagesMock extends BaseModelMock {
data = {
SimpleMessageMock: {
_id : 'SimpleMessageMock',
t : 'uj',
rid : 'GENERAL',
ts : new Date('2019-03-30T01:22:08.389Z'),
msg : 'rocket.cat',
u : {
_id : 'rocket.cat',
username : 'rocket.cat',
_id: 'SimpleMessageMock',
t: 'uj',
rid: 'GENERAL',
ts: new Date('2019-03-30T01:22:08.389Z'),
msg: 'rocket.cat',
u: {
_id: 'rocket.cat',
username: 'rocket.cat',
},
groupable : false,
_updatedAt : new Date('2019-03-30T01:22:08.412Z'),
groupable: false,
_updatedAt: new Date('2019-03-30T01:22:08.412Z'),
},
LivechatGuestMessageMock: {
_id : 'LivechatGuestMessageMock',
rid : 'LivechatRoom',
msg : 'Help wanted',
token : 'guest-token',
alias : 'Livechat Guest',
ts : new Date('2019-04-06T03:57:28.263Z'),
u : {
_id : 'guest1234',
_id: 'LivechatGuestMessageMock',
rid: 'LivechatRoom',
msg: 'Help wanted',
token: 'guest-token',
alias: 'Livechat Guest',
ts: new Date('2019-04-06T03:57:28.263Z'),
u: {
_id: 'guest1234',
username: 'guest1234',
name : 'Livechat Guest',
name: 'Livechat Guest',
},
_updatedAt : new Date('2019-04-06T03:57:28.278Z'),
mentions : [],
channels : [],
_updatedAt: new Date('2019-04-06T03:57:28.278Z'),
mentions: [],
channels: [],
},
}
}

@ -3,18 +3,18 @@ import { BaseModelMock } from './BaseModel.mock';
export class UsersMock extends BaseModelMock {
data = {
'rocket.cat': {
_id : 'rocket.cat',
createdAt : new Date('2019-03-27T20:51:36.821Z'),
avatarOrigin : 'local',
name : 'Rocket.Cat',
username : 'rocket.cat',
status : 'online',
statusDefault : 'online',
utcOffset : 0,
active : true,
type : 'bot',
_updatedAt : new Date('2019-03-30T01:11:50.496Z'),
roles : [
_id: 'rocket.cat',
createdAt: new Date('2019-03-27T20:51:36.821Z'),
avatarOrigin: 'local',
name: 'Rocket.Cat',
username: 'rocket.cat',
status: 'online',
statusDefault: 'online',
utcOffset: 0,
active: true,
type: 'bot',
_updatedAt: new Date('2019-03-30T01:11:50.496Z'),
roles: [
'bot',
],
},

@ -1,6 +1,5 @@
export class AppServerOrchestratorMock {
constructor() {
this._marketplaceUrl = 'https://marketplace.rocket.chat';
this._model = {};

@ -1,17 +1,19 @@
import crypto from 'crypto';
import { Meteor } from 'meteor/meteor';
import { WebApp, WebAppInternals } from 'meteor/webapp';
import { WebAppHashing } from 'meteor/webapp-hashing';
import _ from 'underscore';
import sizeOf from 'image-size';
import sharp from 'sharp';
import { settings } from '../../settings';
import { Settings } from '../../models';
import { getURL } from '../../utils/lib/getURL';
import { mime } from '../../utils/lib/mimeTypes';
import { hasPermission } from '../../authorization';
import { RocketChatFile } from '../../file';
import { WebAppHashing } from 'meteor/webapp-hashing';
import _ from 'underscore';
import sizeOf from 'image-size';
import crypto from 'crypto';
import sharp from 'sharp';
const RocketChatAssetsInstance = new RocketChatFile.GridFS({
name: 'assets',
@ -184,7 +186,7 @@ const assets = {
},
};
export const RocketChatAssets = new (class {
export const RocketChatAssets = new class {
get mime() {
return mime;
}
@ -290,7 +292,7 @@ export const RocketChatAssets = new (class {
const hash = crypto.createHash('sha1').update(file.buffer).digest('hex');
const extension = settingValue.url.split('.').pop();
return assetValue.cache = {
assetValue.cache = {
path: `assets/${ assetKey }.${ extension }`,
cacheable: false,
sourceMapUrl: undefined,
@ -304,6 +306,8 @@ export const RocketChatAssets = new (class {
contentType: file.contentType,
hash,
};
return assetValue.cache;
}
getURL(assetName, options = { cdn: false, full: true }) {
@ -312,7 +316,7 @@ export const RocketChatAssets = new (class {
return getURL(url, options);
}
});
}();
settings.addGroup('Assets');

@ -1,7 +1,8 @@
import { Meteor } from 'meteor/meteor';
import { Template } from 'meteor/templating';
import * as Models from '../../models';
import { ChatPermissions } from './lib/ChatPermissions';
import * as Models from '../../models';
function atLeastOne(permissions = [], scope) {
return permissions.some((permissionId) => {
@ -54,4 +55,3 @@ Template.registerHelper('hasPermission', function(permission, scope) {
export const hasAllPermission = (permissions, scope) => _hasPermission(permissions, scope, all);
export const hasAtLeastOnePermission = (permissions, scope) => _hasPermission(permissions, scope, atLeastOne);
export const hasPermission = hasAllPermission;

@ -1,5 +1,6 @@
import { FlowRouter } from 'meteor/kadira:flow-router';
import { BlazeLayout } from 'meteor/kadira:blaze-layout';
import { t } from '../../utils/client';
FlowRouter.route('/admin/permissions', {

@ -1,10 +1,10 @@
import { Meteor } from 'meteor/meteor';
import { CachedCollectionManager } from '../../ui-cached-collection';
import { hasAllPermission } from './hasPermission';
import { CachedCollectionManager } from '../../ui-cached-collection';
import { AdminBox } from '../../ui-utils/client/lib/AdminBox';
Meteor.startup(() => {
CachedCollectionManager.onLogin(() => Meteor.subscribe('roles'));
AdminBox.addOption({

@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { Notifications } from '../../notifications';
import { RoomRoles } from '../../models';

@ -2,6 +2,7 @@ import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import { Tracker } from 'meteor/tracker';
import { Template } from 'meteor/templating';
import { Roles } from '../../../models';
import { ChatPermissions } from '../lib/ChatPermissions';
import { hasAllPermission } from '../hasPermission';
@ -48,9 +49,8 @@ Template.permissions.events({
if (instance.permissionByRole[permission].indexOf(role) === -1) {
return Meteor.call('authorization:addPermissionToRole', permission, role);
} else {
return Meteor.call('authorization:removeRoleFromPermission', permission, role);
}
return Meteor.call('authorization:removeRoleFromPermission', permission, role);
},
});

@ -2,13 +2,14 @@ import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { Template } from 'meteor/templating';
import { Tracker } from 'meteor/tracker';
import toastr from 'toastr';
import { handleError } from '../../../utils/client/lib/handleError';
import { t } from '../../../utils/lib/tapi18n';
import { Tracker } from 'meteor/tracker';
import { Roles } from '../../../models';
import { hasAllPermission } from '../hasPermission';
import { modal } from '../../../ui-utils/client/lib/modal';
import toastr from 'toastr';
import { SideNav } from '../../../ui-utils/client/lib/SideNav';
Template.permissionsRole.helpers({
@ -225,9 +226,9 @@ Template.permissionsRole.events({
});
Template.permissionsRole.onCreated(function() {
this.searchRoom = new ReactiveVar;
this.searchUsername = new ReactiveVar;
this.usersInRole = new ReactiveVar;
this.searchRoom = new ReactiveVar();
this.searchUsername = new ReactiveVar();
this.usersInRole = new ReactiveVar();
this.limit = new ReactiveVar(50);
this.ready = new ReactiveVar(true);
this.subscribe('roles', FlowRouter.getParam('name'));

@ -1,8 +1,9 @@
import { Meteor } from 'meteor/meteor';
import { Users, Roles } from '../../../models';
import { getRoles } from './getRoles';
import _ from 'underscore';
import { getRoles } from './getRoles';
import { Users, Roles } from '../../../models';
export const addUserRoles = (userId, roleNames, scope) => {
if (!userId || !roleNames) {
return false;

@ -1,6 +1,6 @@
import { hasPermission } from './hasPermission';
import { settings } from '../../../settings';
import Subscriptions from '../../../models/server/models/Subscriptions';
import { hasPermission } from './hasPermission';
export const roomAccessValidators = [
function(room, user = {}) {

@ -1,6 +1,7 @@
import { Meteor } from 'meteor/meteor';
import { Rooms, Subscriptions } from '../../../models';
import { canAccessRoom } from './canAccessRoom';
import { Rooms, Subscriptions } from '../../../models';
export const canSendMessage = (rid, { uid, username }, extraData) => {
const room = Rooms.findOneById(rid);

@ -1,4 +1,3 @@
import { Roles } from '../../../models';
export const getUsersInRole = (roleName, scope, options) => Roles.findUsersInRole(roleName, scope, options);

@ -1,8 +1,9 @@
import { Meteor } from 'meteor/meteor';
import { Users, Roles } from '../../../models';
import { getRoles } from './getRoles';
import _ from 'underscore';
import { getRoles } from './getRoles';
import { Users, Roles } from '../../../models';
export const removeUserFromRoles = (userId, roleNames, scope) => {
if (!userId || !roleNames) {
return false;

@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { Permissions } from '../../../models';
import { hasPermission } from '../functions/hasPermission';

@ -1,9 +1,10 @@
import { Meteor } from 'meteor/meteor';
import _ from 'underscore';
import { Users, Roles } from '../../../models';
import { settings } from '../../../settings';
import { Notifications } from '../../../notifications';
import { hasPermission } from '../functions/hasPermission';
import _ from 'underscore';
Meteor.methods({
'authorization:addUserToRole'(roleName, username, scope) {

@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import * as Models from '../../../models';
import { hasPermission } from '../functions/hasPermission';

@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { Permissions } from '../../../models';
import { hasPermission } from '../functions/hasPermission';

@ -1,9 +1,10 @@
import { Meteor } from 'meteor/meteor';
import _ from 'underscore';
import { Roles } from '../../../models';
import { settings } from '../../../settings';
import { Notifications } from '../../../notifications';
import { hasPermission } from '../functions/hasPermission';
import _ from 'underscore';
Meteor.methods({
'authorization:removeUserFromRole'(roleName, username, scope) {

@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { Roles } from '../../../models';
import { settings } from '../../../settings';
import { Notifications } from '../../../notifications';

@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import Permissions from '../../../models/server/models/Permissions';
import { Notifications } from '../../../notifications';

@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { Roles } from '../../../models';
Meteor.publish('roles', function() {

@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { hasPermission } from '../functions/hasPermission';
import { getUsersInRole } from '../functions/getUsersInRole';

@ -1,5 +1,6 @@
/* eslint no-multi-spaces: 0 */
import { Meteor } from 'meteor/meteor';
import { Roles, Permissions } from '../../models';
Meteor.startup(function() {
@ -8,76 +9,76 @@ Meteor.startup(function() {
// then we can define edit-<type>-message instead of edit-message
// 2. admin, moderator, and user roles should not be deleted as they are referened in the code.
const permissions = [
{ _id: 'access-permissions', roles : ['admin'] },
{ _id: 'add-oauth-service', roles : ['admin'] },
{ _id: 'add-user-to-joined-room', roles : ['admin', 'owner', 'moderator'] },
{ _id: 'add-user-to-any-c-room', roles : ['admin'] },
{ _id: 'add-user-to-any-p-room', roles : [] },
{ _id: 'api-bypass-rate-limit', roles : ['admin', 'bot'] },
{ _id: 'archive-room', roles : ['admin', 'owner'] },
{ _id: 'assign-admin-role', roles : ['admin'] },
{ _id: 'assign-roles', roles : ['admin'] },
{ _id: 'ban-user', roles : ['admin', 'owner', 'moderator'] },
{ _id: 'bulk-create-c', roles : ['admin'] },
{ _id: 'bulk-register-user', roles : ['admin'] },
{ _id: 'create-c', roles : ['admin', 'user', 'bot'] },
{ _id: 'create-d', roles : ['admin', 'user', 'bot'] },
{ _id: 'create-p', roles : ['admin', 'user', 'bot'] },
{ _id: 'create-personal-access-tokens', roles : ['admin', 'user'] },
{ _id: 'create-user', roles : ['admin'] },
{ _id: 'clean-channel-history', roles : ['admin'] },
{ _id: 'delete-c', roles : ['admin', 'owner'] },
{ _id: 'delete-d', roles : ['admin'] },
{ _id: 'delete-message', roles : ['admin', 'owner', 'moderator'] },
{ _id: 'delete-p', roles : ['admin', 'owner'] },
{ _id: 'delete-user', roles : ['admin'] },
{ _id: 'edit-message', roles : ['admin', 'owner', 'moderator'] },
{ _id: 'edit-other-user-active-status', roles : ['admin'] },
{ _id: 'edit-other-user-info', roles : ['admin'] },
{ _id: 'edit-other-user-password', roles : ['admin'] },
{ _id: 'edit-other-user-avatar', roles : ['admin'] },
{ _id: 'edit-privileged-setting', roles : ['admin'] },
{ _id: 'edit-room', roles : ['admin', 'owner', 'moderator'] },
{ _id: 'edit-room-retention-policy', roles : ['admin'] },
{ _id: 'force-delete-message', roles : ['admin', 'owner'] },
{ _id: 'join-without-join-code', roles : ['admin', 'bot'] },
{ _id: 'leave-c', roles : ['admin', 'user', 'bot', 'anonymous'] },
{ _id: 'leave-p', roles : ['admin', 'user', 'bot', 'anonymous'] },
{ _id: 'manage-assets', roles : ['admin'] },
{ _id: 'manage-emoji', roles : ['admin'] },
{ _id: 'manage-integrations', roles : ['admin'] },
{ _id: 'manage-own-integrations', roles : ['admin'] },
{ _id: 'manage-oauth-apps', roles : ['admin'] },
{ _id: 'mention-all', roles : ['admin', 'owner', 'moderator', 'user'] },
{ _id: 'mention-here', roles : ['admin', 'owner', 'moderator', 'user'] },
{ _id: 'mute-user', roles : ['admin', 'owner', 'moderator'] },
{ _id: 'remove-user', roles : ['admin', 'owner', 'moderator'] },
{ _id: 'reset-other-user-e2e-key', roles : ['admin'] },
{ _id: 'run-import', roles : ['admin'] },
{ _id: 'run-migration', roles : ['admin'] },
{ _id: 'set-moderator', roles : ['admin', 'owner'] },
{ _id: 'set-owner', roles : ['admin', 'owner'] },
{ _id: 'send-many-messages', roles : ['admin', 'bot'] },
{ _id: 'set-leader', roles : ['admin', 'owner'] },
{ _id: 'unarchive-room', roles : ['admin'] },
{ _id: 'view-c-room', roles : ['admin', 'user', 'bot', 'anonymous'] },
{ _id: 'user-generate-access-token', roles : ['admin'] },
{ _id: 'view-d-room', roles : ['admin', 'user', 'bot'] },
{ _id: 'view-full-other-user-info', roles : ['admin'] },
{ _id: 'view-history', roles : ['admin', 'user', 'anonymous'] },
{ _id: 'view-joined-room', roles : ['guest', 'bot', 'anonymous'] },
{ _id: 'view-join-code', roles : ['admin'] },
{ _id: 'view-logs', roles : ['admin'] },
{ _id: 'view-other-user-channels', roles : ['admin'] },
{ _id: 'view-p-room', roles : ['admin', 'user', 'anonymous'] },
{ _id: 'view-privileged-setting', roles : ['admin'] },
{ _id: 'view-room-administration', roles : ['admin'] },
{ _id: 'view-statistics', roles : ['admin'] },
{ _id: 'view-user-administration', roles : ['admin'] },
{ _id: 'preview-c-room', roles : ['admin', 'user', 'anonymous'] },
{ _id: 'view-outside-room', roles : ['admin', 'owner', 'moderator', 'user'] },
{ _id: 'view-broadcast-member-list', roles : ['admin', 'owner', 'moderator'] },
{ _id: 'call-management', roles : ['admin', 'owner', 'moderator'] },
{ _id: 'access-permissions', roles: ['admin'] },
{ _id: 'add-oauth-service', roles: ['admin'] },
{ _id: 'add-user-to-joined-room', roles: ['admin', 'owner', 'moderator'] },
{ _id: 'add-user-to-any-c-room', roles: ['admin'] },
{ _id: 'add-user-to-any-p-room', roles: [] },
{ _id: 'api-bypass-rate-limit', roles: ['admin', 'bot'] },
{ _id: 'archive-room', roles: ['admin', 'owner'] },
{ _id: 'assign-admin-role', roles: ['admin'] },
{ _id: 'assign-roles', roles: ['admin'] },
{ _id: 'ban-user', roles: ['admin', 'owner', 'moderator'] },
{ _id: 'bulk-create-c', roles: ['admin'] },
{ _id: 'bulk-register-user', roles: ['admin'] },
{ _id: 'create-c', roles: ['admin', 'user', 'bot'] },
{ _id: 'create-d', roles: ['admin', 'user', 'bot'] },
{ _id: 'create-p', roles: ['admin', 'user', 'bot'] },
{ _id: 'create-personal-access-tokens', roles: ['admin', 'user'] },
{ _id: 'create-user', roles: ['admin'] },
{ _id: 'clean-channel-history', roles: ['admin'] },
{ _id: 'delete-c', roles: ['admin', 'owner'] },
{ _id: 'delete-d', roles: ['admin'] },
{ _id: 'delete-message', roles: ['admin', 'owner', 'moderator'] },
{ _id: 'delete-p', roles: ['admin', 'owner'] },
{ _id: 'delete-user', roles: ['admin'] },
{ _id: 'edit-message', roles: ['admin', 'owner', 'moderator'] },
{ _id: 'edit-other-user-active-status', roles: ['admin'] },
{ _id: 'edit-other-user-info', roles: ['admin'] },
{ _id: 'edit-other-user-password', roles: ['admin'] },
{ _id: 'edit-other-user-avatar', roles: ['admin'] },
{ _id: 'edit-privileged-setting', roles: ['admin'] },
{ _id: 'edit-room', roles: ['admin', 'owner', 'moderator'] },
{ _id: 'edit-room-retention-policy', roles: ['admin'] },
{ _id: 'force-delete-message', roles: ['admin', 'owner'] },
{ _id: 'join-without-join-code', roles: ['admin', 'bot'] },
{ _id: 'leave-c', roles: ['admin', 'user', 'bot', 'anonymous'] },
{ _id: 'leave-p', roles: ['admin', 'user', 'bot', 'anonymous'] },
{ _id: 'manage-assets', roles: ['admin'] },
{ _id: 'manage-emoji', roles: ['admin'] },
{ _id: 'manage-integrations', roles: ['admin'] },
{ _id: 'manage-own-integrations', roles: ['admin'] },
{ _id: 'manage-oauth-apps', roles: ['admin'] },
{ _id: 'mention-all', roles: ['admin', 'owner', 'moderator', 'user'] },
{ _id: 'mention-here', roles: ['admin', 'owner', 'moderator', 'user'] },
{ _id: 'mute-user', roles: ['admin', 'owner', 'moderator'] },
{ _id: 'remove-user', roles: ['admin', 'owner', 'moderator'] },
{ _id: 'reset-other-user-e2e-key', roles: ['admin'] },
{ _id: 'run-import', roles: ['admin'] },
{ _id: 'run-migration', roles: ['admin'] },
{ _id: 'set-moderator', roles: ['admin', 'owner'] },
{ _id: 'set-owner', roles: ['admin', 'owner'] },
{ _id: 'send-many-messages', roles: ['admin', 'bot'] },
{ _id: 'set-leader', roles: ['admin', 'owner'] },
{ _id: 'unarchive-room', roles: ['admin'] },
{ _id: 'view-c-room', roles: ['admin', 'user', 'bot', 'anonymous'] },
{ _id: 'user-generate-access-token', roles: ['admin'] },
{ _id: 'view-d-room', roles: ['admin', 'user', 'bot'] },
{ _id: 'view-full-other-user-info', roles: ['admin'] },
{ _id: 'view-history', roles: ['admin', 'user', 'anonymous'] },
{ _id: 'view-joined-room', roles: ['guest', 'bot', 'anonymous'] },
{ _id: 'view-join-code', roles: ['admin'] },
{ _id: 'view-logs', roles: ['admin'] },
{ _id: 'view-other-user-channels', roles: ['admin'] },
{ _id: 'view-p-room', roles: ['admin', 'user', 'anonymous'] },
{ _id: 'view-privileged-setting', roles: ['admin'] },
{ _id: 'view-room-administration', roles: ['admin'] },
{ _id: 'view-statistics', roles: ['admin'] },
{ _id: 'view-user-administration', roles: ['admin'] },
{ _id: 'preview-c-room', roles: ['admin', 'user', 'anonymous'] },
{ _id: 'view-outside-room', roles: ['admin', 'owner', 'moderator', 'user'] },
{ _id: 'view-broadcast-member-list', roles: ['admin', 'owner', 'moderator'] },
{ _id: 'call-management', roles: ['admin', 'owner', 'moderator'] },
];
for (const permission of permissions) {

@ -1,8 +1,9 @@
import { Meteor } from 'meteor/meteor';
import s from 'underscore.string';
import Autolinker from 'autolinker';
import { settings } from '../../settings';
import { callbacks } from '../../callbacks';
import Autolinker from 'autolinker';
const createAutolinker = () => {
const regUrls = new RegExp(settings.get('AutoLinker_UrlsRegExp'));

@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { settings } from '../../settings';
Meteor.startup(function() {

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

Loading…
Cancel
Save