Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dependency of RocketChat namespace inside rocketchat:ui #13131

Merged
merged 100 commits into from
Jan 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
eb36f8b
Move rocketchat settings to specific package
MarcosSpessatto Dec 21, 2018
4428a97
WIP: Move models from rocketchat-lib to a specific package (server)
MarcosSpessatto Dec 24, 2018
157edc0
Move function from rocketchat:lib to rocketchat:utils to use it in ro…
MarcosSpessatto Dec 24, 2018
7b65a21
Merge branch 'develop' into globals/remove-rocketchat-settings
MarcosSpessatto Dec 24, 2018
4a26cba
Merge branch 'globals/remove-rocketchat-settings' into globals/move-r…
MarcosSpessatto Dec 24, 2018
24cfb4f
Move client models from rocketchat:lib to rocketchat:models
MarcosSpessatto Dec 26, 2018
0683f57
Fix lint
MarcosSpessatto Dec 26, 2018
b26e192
Move rocketchat.info from lib to utils
MarcosSpessatto Dec 27, 2018
8eeac90
Remove directly dependency between lib and migrations
MarcosSpessatto Dec 27, 2018
7080105
Move statistics Model to rocketchat:models
MarcosSpessatto Dec 27, 2018
3d2395c
Create rocketchat:metrics to be able to depacking rocketchat callbacks
MarcosSpessatto Dec 27, 2018
289c478
Move callbacks to specific package
MarcosSpessatto Dec 27, 2018
ccba459
Remove unused dependency
MarcosSpessatto Dec 27, 2018
869c15d
Move rocketchat-notifications to a specific package
MarcosSpessatto Dec 27, 2018
af817df
Move rocketchat-promises to a specific package
MarcosSpessatto Dec 28, 2018
4f1947d
Merge branch 'develop' into globals/remove-rocketchat-settings
MarcosSpessatto Jan 2, 2019
52e95cc
Merge branch 'globals/remove-rocketchat-settings' into globals/move-r…
MarcosSpessatto Jan 2, 2019
a8d506b
remove directly dependency from metrics and models
MarcosSpessatto Jan 3, 2019
42c1ac9
Move CachedCollection from lib to models
MarcosSpessatto Jan 3, 2019
a05c6f5
Move ui models/collections from ui to models
MarcosSpessatto Jan 3, 2019
36ff49e
Move authorization client/ui models to rocketchat:models to be able t…
MarcosSpessatto Jan 3, 2019
dfbcf6b
Merge branch 'globals/move-rocketchat-models' into globals/move-rocke…
MarcosSpessatto Jan 3, 2019
e60d248
Merge branch 'globals/move-rocketchat-metrics' into globals/move-rock…
MarcosSpessatto Jan 3, 2019
2c34342
Merge branch 'globals/move-rocketchat-callbacks' into globals/move-ro…
MarcosSpessatto Jan 3, 2019
e71d2b5
Merge branch 'globals/move-rocketchat-notifications' into globals/mov…
MarcosSpessatto Jan 3, 2019
3ea4cf7
Merge branch 'globals/move-rocketchat-promises' into globals/move-ui-…
MarcosSpessatto Jan 3, 2019
15b52fa
Creation of rocketchat:ui-utils to help decouple rocketchat:lib and r…
MarcosSpessatto Jan 3, 2019
6383ad5
Move some common functions to rocketchat:utils
MarcosSpessatto Jan 3, 2019
86bf84c
Change imports to dynamic imports to avoid directly dependency betwee…
MarcosSpessatto Jan 3, 2019
ec7fd7b
Move authz models to rocketchat:models
MarcosSpessatto Jan 3, 2019
523d704
Remove directly dependency between rocketchat:authz and rocketchat:lib
MarcosSpessatto Jan 3, 2019
c770001
Move some functions from rocketchat:lib to rocketchat:utils
MarcosSpessatto Jan 8, 2019
252ad4c
Add functions to settings package
MarcosSpessatto Jan 8, 2019
0d94009
Convert rocketchat:file-upload to main module structure
MarcosSpessatto Jan 8, 2019
61a71eb
Import FileUpload where it is being used
MarcosSpessatto Jan 8, 2019
5a8d997
Remove FileUpload and fileUploadHandler from globals eslintrc
MarcosSpessatto Jan 8, 2019
f6b7f82
Move some functions to rocketchat:ui-utils
MarcosSpessatto Jan 8, 2019
d64719a
Remove directly dependency between rocketchat:authorization and rocke…
MarcosSpessatto Jan 8, 2019
0932300
Remove dependency between lazy-load and lib
MarcosSpessatto Jan 8, 2019
601008b
Change imports of renderMessageBody from ui-message to ui-utils
MarcosSpessatto Jan 8, 2019
c4dd3aa
Add import of main ready from ui-utils
MarcosSpessatto Jan 8, 2019
f82338e
Convert rocketchat-ui-sidenav to main module structure
MarcosSpessatto Jan 8, 2019
2ffadf0
Add imports of toolbarSearch from ui-sidenav
MarcosSpessatto Jan 8, 2019
545d534
Remove toolbarSearch from eslintrc globals
MarcosSpessatto Jan 8, 2019
c4320ea
Move CachedCollection to a specific package
MarcosSpessatto Jan 9, 2019
0ff6b3e
Change imports of CachedCollection to new package
MarcosSpessatto Jan 9, 2019
803abf6
Move some functions to rocketchat:ui-utils
MarcosSpessatto Jan 9, 2019
76ee0f0
Remove directly dependency between tooltip and lib
MarcosSpessatto Jan 9, 2019
6455fbc
Remove directly dependency between settings and metrics
MarcosSpessatto Jan 9, 2019
772e87c
Move some settings client function from lib to settings
MarcosSpessatto Jan 9, 2019
0f16f53
Convert rocketchat-ui-master to main module structure
MarcosSpessatto Jan 9, 2019
c652612
Remove directly dependency between rocketchat:e2e and rocketchat:lib
MarcosSpessatto Jan 10, 2019
85c72bd
Fix wrong import and lint
MarcosSpessatto Jan 10, 2019
c61d834
Convert rocketchat-webrtc to main module structure
MarcosSpessatto Jan 10, 2019
303613b
Fix missing export
MarcosSpessatto Jan 10, 2019
58e4389
Remove directly dependency between rocketchat:emoji and lib
MarcosSpessatto Jan 10, 2019
b9a377d
Add emoji dependencies inside RocketChat namespace
MarcosSpessatto Jan 10, 2019
b40ea2d
Merge branch 'develop' into globals/move-rocketchat-callbacks
MarcosSpessatto Jan 10, 2019
ac03e2d
Merge branch 'develop' into globals/move-rocketchat-callbacks
MarcosSpessatto Jan 10, 2019
483650d
Merge branch 'globals/move-rocketchat-callbacks' into globals/move-ro…
MarcosSpessatto Jan 10, 2019
63bb0a4
Merge branch 'globals/move-rocketchat-notifications' into globals/mov…
MarcosSpessatto Jan 10, 2019
f052372
Merge branch 'globals/move-rocketchat-promises' into globals/move-ui-…
MarcosSpessatto Jan 10, 2019
6fb8b0b
Merge branch 'globals/move-ui-collections' into globals/authorization
MarcosSpessatto Jan 10, 2019
839c7a1
Merge branch 'globals/authorization' into globals/main-module-file-up…
MarcosSpessatto Jan 10, 2019
db361ac
Merge branch 'develop' into globals/move-rocketchat-notifications
rodrigok Jan 10, 2019
30df39b
Merge branch 'globals/move-rocketchat-notifications' into globals/mov…
MarcosSpessatto Jan 10, 2019
e50de55
Merge branch 'globals/move-rocketchat-promises' into globals/move-ui-…
MarcosSpessatto Jan 10, 2019
dba0ec5
Merge branch 'globals/move-ui-collections' into globals/authorization
MarcosSpessatto Jan 10, 2019
488a311
Merge branch 'globals/authorization' into globals/main-module-file-up…
MarcosSpessatto Jan 10, 2019
a177d27
Merge branch 'globals/main-module-file-upload' into globals/main-modu…
MarcosSpessatto Jan 10, 2019
f500d47
Merge branch 'globals/main-module-ui-sidenav' into globals/main-modul…
MarcosSpessatto Jan 10, 2019
dd3294c
Merge branch 'globals/main-module-ui-master' into globals/main-module…
MarcosSpessatto Jan 10, 2019
9b4c7a5
Merge branch 'globals/main-module-e2e' into globals/web-rtc
MarcosSpessatto Jan 10, 2019
605376e
Merge branch 'globals/web-rtc' into globals/emoji
MarcosSpessatto Jan 10, 2019
6c06061
Merge branch 'develop' into globals/authorization
rodrigok Jan 10, 2019
d4c52bb
Move some functions to utils
MarcosSpessatto Jan 11, 2019
cee8b74
Fix lint
MarcosSpessatto Jan 11, 2019
890a363
Merge branch 'globals/emoji' into globals/utils-functions
MarcosSpessatto Jan 11, 2019
31e876f
Move some ui functions to ui-utils
MarcosSpessatto Jan 11, 2019
6969209
Merge branch 'globals/authorization' into globals/main-module-file-up…
MarcosSpessatto Jan 11, 2019
b0aff80
Merge branch 'globals/main-module-file-upload' into globals/main-modu…
MarcosSpessatto Jan 11, 2019
0640958
Fix import missed objects inside RocketChat namespace
MarcosSpessatto Jan 11, 2019
fc30b19
Merge branch 'globals/main-module-ui-sidenav' into globals/main-modul…
MarcosSpessatto Jan 11, 2019
824090d
Merge branch 'globals/main-module-ui-master' into globals/main-module…
MarcosSpessatto Jan 11, 2019
4a53cc4
Merge branch 'globals/main-module-e2e' into globals/web-rtc
MarcosSpessatto Jan 11, 2019
c27b343
Merge branch 'globals/web-rtc' into globals/emoji
MarcosSpessatto Jan 11, 2019
a575e54
Fix lint
MarcosSpessatto Jan 11, 2019
f2bc83a
Merge branch 'globals/main-module-ui-sidenav' into globals/main-modul…
MarcosSpessatto Jan 11, 2019
af87316
Merge branch 'globals/main-module-ui-master' into globals/main-module…
MarcosSpessatto Jan 11, 2019
ea3caa2
Merge branch 'globals/main-module-e2e' into globals/web-rtc
MarcosSpessatto Jan 11, 2019
cd4f6d8
Merge branch 'globals/web-rtc' into globals/emoji
MarcosSpessatto Jan 11, 2019
4592ca1
Merge branch 'globals/emoji' into globals/utils-functions
MarcosSpessatto Jan 11, 2019
8750016
Merge branch 'globals/utils-functions' into globals/ui-utils-functions
MarcosSpessatto Jan 11, 2019
7c788ca
Remove rocketchat:ui package dependency of RocketChat namespace
MarcosSpessatto Jan 11, 2019
27c8d79
Remove lib dependency in rocketchat:ui-sidenav
MarcosSpessatto Jan 11, 2019
ad557d8
Remove dependency between lib and ui-vrecord
MarcosSpessatto Jan 11, 2019
9837311
Add logger dependency in file-upload
MarcosSpessatto Jan 11, 2019
2fa3591
Revert commented test file
MarcosSpessatto Jan 11, 2019
48b2095
Merge branch 'globals/ui-utils-functions' into globals/ui-package
MarcosSpessatto Jan 11, 2019
c5bcfa5
Merge remote-tracking branch 'origin/develop' into globals/ui-package
rodrigok Jan 15, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/rocketchat-file-upload/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Package.onUse(function(api) {
'rocketchat:settings',
'rocketchat:callbacks',
'rocketchat:authorization',
'rocketchat:logger',
'random',
'accounts-base',
'tracker',
Expand Down
7 changes: 7 additions & 0 deletions packages/rocketchat-lib/client/lib/ui-buttons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Login, Button, animationSupport, animeBack, preLoadImgs } from 'meteor/rocketchat:ui';

RocketChat.Login = Login;
RocketChat.Button = Button;
RocketChat.animationSupport = animationSupport;
RocketChat.animeBack = animeBack;
RocketChat.preLoadImgs = preLoadImgs;
2 changes: 2 additions & 0 deletions packages/rocketchat-lib/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Package.onUse(function(api) {
api.use('rocketchat:ui-utils');
api.use('rocketchat:tooltip');
api.use('rocketchat:emoji');
api.use('rocketchat:ui');
api.use('rocketchat:accounts');
api.use('modules');
api.use('rocketchat:i18n');
Expand Down Expand Up @@ -240,6 +241,7 @@ Package.onUse(function(api) {
api.addFiles('client/lib/authorization.js', 'client');
api.addFiles('client/lib/tooltip.js', 'client');
api.addFiles('client/lib/EmojiPicker.js', 'client');
api.addFiles('client/lib/ui-buttons.js', 'client');

// CLIENT LIB STARTUP
api.addFiles('client/lib/startup/commands.js', 'client');
Expand Down
1 change: 0 additions & 1 deletion packages/rocketchat-ui-sidenav/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Package.onUse(function(api) {
api.use([
'ecmascript',
'templating',
'rocketchat:lib',
'rocketchat:callbacks',
'rocketchat:authorization',
'rocketchat:settings',
Expand Down
1 change: 0 additions & 1 deletion packages/rocketchat-ui-utils/client/lib/RoomManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const onDeleteMessageBulkStream = ({ rid, ts, excludePinned, users }) => {

export const RoomManager = new function() {
const openedRooms = {};
let openedRoom = undefined; //eslint-disable-line
const msgStream = new Meteor.Streamer('room-messages');
const onlineUsers = new ReactiveVar({});
const Dep = new Tracker.Dependency();
Expand Down
3 changes: 2 additions & 1 deletion packages/rocketchat-ui-vrecord/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ Package.onUse(function(api) {
'ecmascript',
'templating',
'tracker',
'rocketchat:lib',
'rocketchat:settings',
'rocketchat:ui',
]);
api.addFiles('client/vrecord.css', 'client');
api.mainModule('server/index.js', 'server');
Expand Down
4 changes: 2 additions & 2 deletions packages/rocketchat-ui-vrecord/server/settings.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { RocketChat } from 'meteor/rocketchat:lib';
import { settings } from 'meteor/rocketchat:settings';

RocketChat.settings.addGroup('Message', function() {
settings.addGroup('Message', function() {
this.add('Message_VideoRecorderEnabled', true, {
type: 'boolean',
public: true,
Expand Down
29 changes: 16 additions & 13 deletions packages/rocketchat-ui/client/components/header/header.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { Meteor } from 'meteor/meteor';
import { Session } from 'meteor/session';
import { Template } from 'meteor/templating';
import { t } from 'meteor/rocketchat:utils';
import { t, roomTypes, handleError } from 'meteor/rocketchat:utils';
import { TabBar, fireGlobalEvent } from 'meteor/rocketchat:ui-utils';
import { ChatSubscription, Rooms } from 'meteor/rocketchat:models';
import { settings } from 'meteor/rocketchat:settings';

const isSubscribed = (_id) => ChatSubscription.find({ rid: _id }).count() > 0;

const favoritesEnabled = () => RocketChat.settings.get('Favorite_Rooms');
const favoritesEnabled = () => settings.get('Favorite_Rooms');

Template.header.helpers({
back() {
Expand All @@ -14,15 +17,15 @@ Template.header.helpers({
avatarBackground() {
const roomData = Session.get(`roomData${ this._id }`);
if (!roomData) { return ''; }
return RocketChat.roomTypes.getSecondaryRoomName(roomData.t, roomData) || RocketChat.roomTypes.getRoomName(roomData.t, roomData);
return roomTypes.getSecondaryRoomName(roomData.t, roomData) || roomTypes.getRoomName(roomData.t, roomData);
},
buttons() {
return RocketChat.TabBar.getButtons();
return TabBar.getButtons();
},

isTranslated() {
const sub = ChatSubscription.findOne({ rid: this._id }, { fields: { autoTranslate: 1, autoTranslateLanguage: 1 } });
return RocketChat.settings.get('AutoTranslate_Enabled') && ((sub != null ? sub.autoTranslate : undefined) === true) && (sub.autoTranslateLanguage != null);
return settings.get('AutoTranslate_Enabled') && ((sub != null ? sub.autoTranslate : undefined) === true) && (sub.autoTranslateLanguage != null);
},

state() {
Expand All @@ -38,21 +41,21 @@ Template.header.helpers({
},

isDirect() {
return RocketChat.models.Rooms.findOne(this._id).t === 'd';
return Rooms.findOne(this._id).t === 'd';
},

roomName() {
const roomData = Session.get(`roomData${ this._id }`);
if (!roomData) { return ''; }

return RocketChat.roomTypes.getRoomName(roomData.t, roomData);
return roomTypes.getRoomName(roomData.t, roomData);
},

secondaryName() {
const roomData = Session.get(`roomData${ this._id }`);
if (!roomData) { return ''; }

return RocketChat.roomTypes.getSecondaryRoomName(roomData.t, roomData);
return roomTypes.getSecondaryRoomName(roomData.t, roomData);
},

roomTopic() {
Expand All @@ -62,7 +65,7 @@ Template.header.helpers({
},

channelIcon() {
const roomType = RocketChat.models.Rooms.findOne(this._id).t;
const roomType = Rooms.findOne(this._id).t;
switch (roomType) {
case 'd':
return 'at';
Expand All @@ -73,15 +76,15 @@ Template.header.helpers({
case 'l':
return 'livechat';
default:
return RocketChat.roomTypes.getIcon(roomType);
return roomTypes.getIcon(roomType);
}
},

roomIcon() {
const roomData = Session.get(`roomData${ this._id }`);
if (!(roomData != null ? roomData.t : undefined)) { return ''; }

return RocketChat.roomTypes.getIcon(roomData != null ? roomData.t : undefined);
return roomTypes.getIcon(roomData != null ? roomData.t : undefined);
},

encryptedChannel() {
Expand All @@ -91,7 +94,7 @@ Template.header.helpers({

userStatus() {
const roomData = Session.get(`roomData${ this._id }`);
return RocketChat.roomTypes.getUserStatus(roomData.t, this._id) || t('offline');
return roomTypes.getUserStatus(roomData.t, this._id) || t('offline');
},

showToggleFavorite() {
Expand Down Expand Up @@ -146,5 +149,5 @@ Template.header.events({
});

Template.header.onCreated(function() {
this.currentChannel = (this.data && this.data._id && RocketChat.models.Rooms.findOne(this.data._id)) || undefined;
this.currentChannel = (this.data && this.data._id && Rooms.findOne(this.data._id)) || undefined;
});
3 changes: 2 additions & 1 deletion packages/rocketchat-ui/client/components/popupList.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Template } from 'meteor/templating';
import { settings } from 'meteor/rocketchat:settings';

Template.popupList.helpers({
config() {
Expand Down Expand Up @@ -34,6 +35,6 @@ Template.popupList_default.helpers({

Template.popupList_item_default.helpers({
showRealNames() {
return RocketChat.settings.get('UI_Use_Real_Name');
return settings.get('UI_Use_Real_Name');
},
});
1 change: 1 addition & 0 deletions packages/rocketchat-ui/client/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Button, Login, animationSupport, animeBack, preLoadImgs } from './lib/rocket';
53 changes: 30 additions & 23 deletions packages/rocketchat-ui/client/lib/chatMessages.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ import { Tracker } from 'meteor/tracker';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { Session } from 'meteor/session';
import { TAPi18n } from 'meteor/tap:i18n';
import { t } from 'meteor/rocketchat:utils';
import { t, getUserPreference, slashCommands, handleError } from 'meteor/rocketchat:utils';
import { MessageAction, messageProperties, MessageTypes, readMessage, modal } from 'meteor/rocketchat:ui-utils';
import { settings } from 'meteor/rocketchat:settings';
import { callbacks } from 'meteor/rocketchat:callbacks';
import { promises } from 'meteor/rocketchat:promises';
import { hasAtLeastOnePermission } from 'meteor/rocketchat:authorization';
import { Messages, Rooms, ChatMessage } from 'meteor/rocketchat:models';
import { emoji } from 'meteor/rocketchat:emoji';
import _ from 'underscore';
import s from 'underscore.string';
import moment from 'moment';
Expand All @@ -16,7 +23,7 @@ let sendOnEnter = '';
Meteor.startup(() => {
Tracker.autorun(function() {
const user = Meteor.userId();
sendOnEnter = RocketChat.getUserPreference(user, 'sendOnEnter');
sendOnEnter = getUserPreference(user, 'sendOnEnter');
});
});

Expand All @@ -32,7 +39,7 @@ ChatMessages = class ChatMessages {
init(node) {
this.editing = {};
this.records = {};
this.messageMaxSize = RocketChat.settings.get('Message_MaxAllowedSize');
this.messageMaxSize = settings.get('Message_MaxAllowedSize');
this.wrapper = $(node).find('.wrapper');
this.input = this.input || $(node).find('.js-input-message').get(0);
this.$input = $(this.input);
Expand Down Expand Up @@ -120,14 +127,14 @@ ChatMessages = class ChatMessages {

const message = this.getMessageById(element.getAttribute('id'));

const hasPermission = RocketChat.authz.hasAtLeastOnePermission('edit-message', message.rid);
const editAllowed = RocketChat.settings.get('Message_AllowEditing');
const hasPermission = hasAtLeastOnePermission('edit-message', message.rid);
const editAllowed = settings.get('Message_AllowEditing');
const editOwn = message && message.u && message.u._id === Meteor.userId();

if (!hasPermission && (!editAllowed || !editOwn)) { return; }
if (element.classList.contains('system')) { return; }

const blockEditInMinutes = RocketChat.settings.get('Message_AllowEditing_BlockEditInMinutes');
const blockEditInMinutes = settings.get('Message_AllowEditing_BlockEditInMinutes');
if (blockEditInMinutes && blockEditInMinutes !== 0) {
let currentTsDiff;
let msgTs;
Expand Down Expand Up @@ -211,8 +218,8 @@ ChatMessages = class ChatMessages {
const mentionUser = $(input).data('mention-user') || false;

if (reply !== undefined) {
msg = `[ ](${ await RocketChat.MessageAction.getPermaLink(reply._id) }) `;
const roomInfo = RocketChat.models.Rooms.findOne(reply.rid, { fields: { t: 1 } });
msg = `[ ](${ await MessageAction.getPermaLink(reply._id) }) `;
const roomInfo = Rooms.findOne(reply.rid, { fields: { t: 1 } });
if (roomInfo.t !== 'd' && reply.u.username !== Meteor.user().username && mentionUser) {
msg += `@${ reply.u.username } `;
}
Expand All @@ -225,7 +232,7 @@ ChatMessages = class ChatMessages {

if (msg.slice(0, 2) === '+:') {
const reaction = msg.slice(1).trim();
if (RocketChat.emoji.list[reaction]) {
if (emoji.list[reaction]) {
const lastMessage = ChatMessage.findOne({ rid }, { fields: { ts: 1 }, sort: { ts: -1 } });
Meteor.call('setReaction', reaction, lastMessage._id);
input.value = '';
Expand All @@ -235,7 +242,7 @@ ChatMessages = class ChatMessages {
}

// Run to allow local encryption, and maybe other client specific actions to be run before send
const msgObject = await RocketChat.promises.run('onClientBeforeSendMessage', { _id: Random.id(), rid, msg });
const msgObject = await promises.run('onClientBeforeSendMessage', { _id: Random.id(), rid, msg });

// checks for the final msgObject.msg size before actually sending the message
if (this.isMessageTooLong(msgObject.msg)) {
Expand Down Expand Up @@ -290,12 +297,12 @@ ChatMessages = class ChatMessages {
const match = msgObject.msg.match(/^\/([^\s]+)(?:\s+(.*))?$/m);
if (match) {
let command;
if (RocketChat.slashCommands.commands[match[1]]) {
const commandOptions = RocketChat.slashCommands.commands[match[1]];
if (slashCommands.commands[match[1]]) {
const commandOptions = slashCommands.commands[match[1]];
command = match[1];
const param = match[2] || '';

if (!commandOptions.permission || RocketChat.authz.hasAtLeastOnePermission(commandOptions.permission, Session.get('openedRoom'))) {
if (!commandOptions.permission || hasAtLeastOnePermission(commandOptions.permission, Session.get('openedRoom'))) {
if (commandOptions.clientOnly) {
commandOptions.callback(command, param, msgObject);
} else {
Expand All @@ -306,14 +313,14 @@ ChatMessages = class ChatMessages {
}
}

if (!RocketChat.settings.get('Message_AllowUnrecognizedSlashCommand')) {
if (!settings.get('Message_AllowUnrecognizedSlashCommand')) {
const invalidCommandMsg = {
_id: Random.id(),
rid: msgObject.rid,
ts: new Date,
msg: TAPi18n.__('No_such_command', { command: match[1] }),
u: {
username: RocketChat.settings.get('InternalHubot_Username'),
username: settings.get('InternalHubot_Username'),
},
private: true,
};
Expand All @@ -328,7 +335,7 @@ ChatMessages = class ChatMessages {
}

confirmDeleteMsg(message, done = function() {}) {
if (RocketChat.MessageTypes.isSystemMessage(message)) { return; }
if (MessageTypes.isSystemMessage(message)) { return; }
modal.open({
title: t('Are_you_sure'),
text: t('You_will_not_be_able_to_recover'),
Expand Down Expand Up @@ -358,8 +365,8 @@ ChatMessages = class ChatMessages {
}

deleteMsg(message) {
const forceDelete = RocketChat.authz.hasAtLeastOnePermission('force-delete-message', message.rid);
const blockDeleteInMinutes = RocketChat.settings.get('Message_AllowDeleting_BlockDeleteInMinutes');
const forceDelete = hasAtLeastOnePermission('force-delete-message', message.rid);
const blockDeleteInMinutes = settings.get('Message_AllowDeleting_BlockDeleteInMinutes');
if (blockDeleteInMinutes && forceDelete === false) {
let msgTs;
if (message.ts != null) { msgTs = moment(message.ts); }
Expand Down Expand Up @@ -460,7 +467,7 @@ ChatMessages = class ChatMessages {
if (!msgId) {
return;
}
const message = RocketChat.models.Messages.findOne(msgId);
const message = Messages.findOne(msgId);
if (message) {
return this.$input.data('reply', message).trigger('dataChange');
}
Expand Down Expand Up @@ -594,8 +601,8 @@ ChatMessages = class ChatMessages {
}

isMessageTooLong(message) {
const adjustedMessage = RocketChat.messageProperties.messageWithoutEmojiShortnames(message);
return RocketChat.messageProperties.length(adjustedMessage) > this.messageMaxSize && message;
const adjustedMessage = messageProperties.messageWithoutEmojiShortnames(message);
return messageProperties.length(adjustedMessage) > this.messageMaxSize && message;
}

isEmpty() {
Expand All @@ -604,10 +611,10 @@ ChatMessages = class ChatMessages {
};


RocketChat.callbacks.add('afterLogoutCleanUp', () => {
callbacks.add('afterLogoutCleanUp', () => {
Object.keys(localStorage).forEach((item) => {
if (item.indexOf('messagebox_') === 0) {
localStorage.removeItem(item);
}
});
}, RocketChat.callbacks.priority.MEDIUM, 'chatMessages-after-logout-cleanup');
}, callbacks.priority.MEDIUM, 'chatMessages-after-logout-cleanup');
3 changes: 2 additions & 1 deletion packages/rocketchat-ui/client/lib/collections.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';
import { settings } from 'meteor/rocketchat:settings';
import {
ChatMessage as chatMessage,
CachedChatRoom as cachedChatRoom,
Expand Down Expand Up @@ -27,7 +28,7 @@ this.CachedUserList = cachedUserList;

Meteor.startup(() => {
Tracker.autorun(() => {
if (!Meteor.userId() && RocketChat.settings.get('Accounts_AllowAnonymousRead') === true) {
if (!Meteor.userId() && settings.get('Accounts_AllowAnonymousRead') === true) {
CachedChatRoom.init();
CachedChatSubscription.ready.set(true);
}
Expand Down
3 changes: 2 additions & 1 deletion packages/rocketchat-ui/client/lib/cordova/push.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { Push } from 'meteor/rocketchat:push';
import { settings } from 'meteor/rocketchat:settings';

if (Meteor.isCordova) {
// Push.addListener 'token', (token) ->
Expand Down Expand Up @@ -72,7 +73,7 @@ if (Meteor.isCordova) {

Meteor.startup(() =>
Tracker.autorun(() => {
if (RocketChat.settings.get('Push_enable') === true) {
if (settings.get('Push_enable') === true) {

Push.Configure({
android: {
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-ui/client/lib/cordova/user-state.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Meteor } from 'meteor/meteor';
import { UserPresence } from 'meteor/konecty:user-presence';
import { readMessage } from 'meteor/rocketchat:ui-utils';
import _ from 'underscore';

let timer = undefined;
Expand Down
Loading