Skip to content

Commit

Permalink
Merge branch 'develop' into regression/geolocation
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcosSpessatto authored Feb 15, 2019
2 parents 66066f1 + 1a46bb0 commit 0e6ff28
Show file tree
Hide file tree
Showing 435 changed files with 3,106 additions and 2,544 deletions.
1 change: 0 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"globals": {
"__meteor_bootstrap__" : false,
"__meteor_runtime_config__" : false,
"Apps" : false,
"Assets" : false,
"chrome" : false,
"DynamicCss" : false,
Expand Down
10 changes: 6 additions & 4 deletions client/methods/deleteMessage.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';
import { ChatMessage } from 'meteor/rocketchat:models';
import { hasAtLeastOnePermission } from 'meteor/rocketchat:authorization';
import { settings } from 'meteor/rocketchat:settings';
import _ from 'underscore';
import moment from 'moment';

Expand All @@ -13,9 +15,9 @@ Meteor.methods({
// We're now only passed in the `_id` property to lower the amount of data sent to the server
message = ChatMessage.findOne({ _id: message._id });

const hasPermission = RocketChat.authz.hasAtLeastOnePermission('delete-message', message.rid);
const forceDelete = RocketChat.authz.hasAtLeastOnePermission('force-delete-message', message.rid);
const deleteAllowed = RocketChat.settings.get('Message_AllowDeleting');
const hasPermission = hasAtLeastOnePermission('delete-message', message.rid);
const forceDelete = hasAtLeastOnePermission('force-delete-message', message.rid);
const deleteAllowed = settings.get('Message_AllowDeleting');
let deleteOwn = false;

if (message && message.u && message.u._id) {
Expand All @@ -24,7 +26,7 @@ Meteor.methods({
if (!(forceDelete || hasPermission || (deleteAllowed && deleteOwn))) {
return false;
}
const blockDeleteInMinutes = RocketChat.settings.get('Message_AllowDeleting_BlockDeleteInMinutes');
const blockDeleteInMinutes = settings.get('Message_AllowDeleting_BlockDeleteInMinutes');
if (!forceDelete && _.isNumber(blockDeleteInMinutes) && blockDeleteInMinutes !== 0) {
const msgTs = moment(message.ts);
const currentTsDiff = moment().diff(msgTs, 'minutes');
Expand Down
11 changes: 7 additions & 4 deletions client/methods/updateMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { Tracker } from 'meteor/tracker';
import { TimeSync } from 'meteor/mizzao:timesync';
import { t } from 'meteor/rocketchat:utils';
import { ChatMessage } from 'meteor/rocketchat:models';
import { hasAtLeastOnePermission } from 'meteor/rocketchat:authorization';
import { settings } from 'meteor/rocketchat:settings';
import { callbacks } from 'meteor/rocketchat:callbacks';
import _ from 'underscore';
import moment from 'moment';
import toastr from 'toastr';
Expand All @@ -15,8 +18,8 @@ Meteor.methods({

const originalMessage = ChatMessage.findOne(message._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');
let editOwn = false;
if (originalMessage.msg === message.msg) {
return;
Expand All @@ -32,7 +35,7 @@ Meteor.methods({
return false;
}

const blockEditInMinutes = RocketChat.settings.get('Message_AllowEditing_BlockEditInMinutes');
const blockEditInMinutes = settings.get('Message_AllowEditing_BlockEditInMinutes');
if (_.isNumber(blockEditInMinutes) && blockEditInMinutes !== 0) {
if (originalMessage.ts) {
const msgTs = moment(originalMessage.ts);
Expand All @@ -59,7 +62,7 @@ Meteor.methods({
username: me.username,
};

message = RocketChat.callbacks.run('beforeSaveMessage', message);
message = callbacks.run('beforeSaveMessage', message);
const messageObject = { editedAt: message.editedAt, editedBy: message.editedBy, msg: message.msg };

if (originalMessage.attachments) {
Expand Down
10 changes: 6 additions & 4 deletions client/notifications/UsersNameChanged.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { Meteor } from 'meteor/meteor';
import { Notifications } from 'meteor/rocketchat:notifications';
import { Messages, Subscriptions } from 'meteor/rocketchat:models';

Meteor.startup(function() {
RocketChat.Notifications.onLogged('Users:NameChanged', function({ _id, name, username }) {
RocketChat.models.Messages.update({
Notifications.onLogged('Users:NameChanged', function({ _id, name, username }) {
Messages.update({
'u._id': _id,
}, {
$set: {
Expand All @@ -12,7 +14,7 @@ Meteor.startup(function() {
multi: true,
});

RocketChat.models.Messages.update({
Messages.update({
mentions: {
$elemMatch: { _id },
},
Expand All @@ -24,7 +26,7 @@ Meteor.startup(function() {
multi: true,
});

RocketChat.models.Subscriptions.update({
Subscriptions.update({
name: username,
t: 'd',
}, {
Expand Down
20 changes: 12 additions & 8 deletions client/notifications/notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { Session } from 'meteor/session';
import { KonchatNotification, fireGlobalEvent, readMessage, CachedChatSubscription } from 'meteor/rocketchat:ui';
import { KonchatNotification } from 'meteor/rocketchat:ui';
import { CachedChatSubscription } from 'meteor/rocketchat:models';
import { fireGlobalEvent, readMessage, Layout } from 'meteor/rocketchat:ui-utils';
import { getUserPreference } from 'meteor/rocketchat:utils';
import { Notifications } from 'meteor/rocketchat:notifications';

// Show notifications and play a sound for new messages.
// We trust the server to only send notifications for interesting messages, e.g. direct messages or
Expand All @@ -23,7 +27,7 @@ function notifyNewRoom(sub) {
Meteor.startup(function() {
Tracker.autorun(function() {
if (Meteor.userId()) {
RocketChat.Notifications.onUser('notification', function(notification) {
Notifications.onUser('notification', function(notification) {

let openedRoomId = undefined;
if (['channel', 'group', 'direct'].includes(FlowRouter.getRouteName())) {
Expand All @@ -33,15 +37,15 @@ Meteor.startup(function() {
// This logic is duplicated in /client/startup/unread.coffee.
const hasFocus = readMessage.isEnable();
const messageIsInOpenedRoom = openedRoomId === notification.payload.rid;
const muteFocusedConversations = RocketChat.getUserPreference(Meteor.userId(), 'muteFocusedConversations');
const muteFocusedConversations = getUserPreference(Meteor.userId(), 'muteFocusedConversations');

fireGlobalEvent('notification', {
notification,
fromOpenedRoom: messageIsInOpenedRoom,
hasFocus,
});

if (RocketChat.Layout.isEmbedded()) {
if (Layout.isEmbedded()) {
if (!hasFocus && messageIsInOpenedRoom) {
// Play a sound and show a notification.
KonchatNotification.newMessage(notification.payload.rid);
Expand All @@ -57,16 +61,16 @@ Meteor.startup(function() {
}
});

RocketChat.Notifications.onUser('audioNotification', function(notification) {
Notifications.onUser('audioNotification', function(notification) {

const openedRoomId = Session.get('openedRoom');

// This logic is duplicated in /client/startup/unread.coffee.
const hasFocus = readMessage.isEnable();
const messageIsInOpenedRoom = openedRoomId === notification.payload.rid;
const muteFocusedConversations = RocketChat.getUserPreference(Meteor.userId(), 'muteFocusedConversations');
const muteFocusedConversations = getUserPreference(Meteor.userId(), 'muteFocusedConversations');

if (RocketChat.Layout.isEmbedded()) {
if (Layout.isEmbedded()) {
if (!hasFocus && messageIsInOpenedRoom) {
// Play a notification sound
KonchatNotification.newMessage(notification.payload.rid);
Expand All @@ -83,7 +87,7 @@ Meteor.startup(function() {
}
};

RocketChat.Notifications.onUser('subscriptions-changed', (action, sub) => {
Notifications.onUser('subscriptions-changed', (action, sub) => {
notifyNewRoom(sub);
});
}
Expand Down
5 changes: 3 additions & 2 deletions client/notifications/updateAvatar.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Meteor } from 'meteor/meteor';
import { updateAvatarOfUsername } from 'meteor/rocketchat:ui';
import { updateAvatarOfUsername } from 'meteor/rocketchat:ui-utils';
import { Notifications } from 'meteor/rocketchat:notifications';

Meteor.startup(function() {
RocketChat.Notifications.onLogged('updateAvatar', function(data) {
Notifications.onLogged('updateAvatar', function(data) {
updateAvatarOfUsername(data.username);
});
});
5 changes: 3 additions & 2 deletions client/notifications/updateUserState.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Meteor } from 'meteor/meteor';
import { fireGlobalEvent } from 'meteor/rocketchat:ui';
import { fireGlobalEvent } from 'meteor/rocketchat:ui-utils';
import { callbacks } from 'meteor/rocketchat:callbacks';

/* fire user state change globally, to listen on desktop electron client */
Meteor.startup(function() {
RocketChat.callbacks.add('userStatusManuallySet', (status) => {
callbacks.add('userStatusManuallySet', (status) => {
fireGlobalEvent('user-status-manually-set', status);
});
});
3 changes: 2 additions & 1 deletion client/routes/roomRoute.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { FlowRouter } from 'meteor/kadira:flow-router';
import { ChatSubscription } from 'meteor/rocketchat:models';
import { roomTypes } from 'meteor/rocketchat:utils';

FlowRouter.goToRoomById = (roomId) => {
const subscription = ChatSubscription.findOne({ rid: roomId });
if (subscription) {
RocketChat.roomTypes.openRouteLink(subscription.t, subscription, FlowRouter.current().queryParams);
roomTypes.openRouteLink(subscription.t, subscription, FlowRouter.current().queryParams);
}
};
3 changes: 2 additions & 1 deletion client/routes/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { FlowRouter } from 'meteor/kadira:flow-router';
import { BlazeLayout } from 'meteor/kadira:blaze-layout';
import { Session } from 'meteor/session';
import { KonchatNotification } from 'meteor/rocketchat:ui';
import { Layout } from 'meteor/rocketchat:ui-utils';
import s from 'underscore.string';

Blaze.registerHelper('pathFor', function(path, kw) {
Expand All @@ -27,7 +28,7 @@ FlowRouter.subscriptions = function() {
FlowRouter.route('/', {
name: 'index',
action() {
BlazeLayout.render('main', { modal: RocketChat.Layout.isEmbedded(), center: 'loading' });
BlazeLayout.render('main', { modal: Layout.isEmbedded(), center: 'loading' });
if (!Meteor.userId()) {
return FlowRouter.go('home');
}
Expand Down
3 changes: 2 additions & 1 deletion client/startup/emailVerification.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';
import { Session } from 'meteor/session';
import { TAPi18n } from 'meteor/tap:i18n';
import { settings } from 'meteor/rocketchat:settings';
import toastr from 'toastr';

Meteor.startup(function() {
Tracker.autorun(function() {
const user = Meteor.user();
if (user && user.emails && user.emails[0] && user.emails[0].verified !== true && RocketChat.settings.get('Accounts_EmailVerification') === true && !Session.get('Accounts_EmailVerification_Warning')) {
if (user && user.emails && user.emails[0] && user.emails[0].verified !== true && settings.get('Accounts_EmailVerification') === true && !Session.get('Accounts_EmailVerification_Warning')) {
toastr.warning(TAPi18n.__('You_have_not_verified_your_email'));
Session.set('Accounts_EmailVerification_Warning', true);
}
Expand Down
6 changes: 4 additions & 2 deletions client/startup/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { ReactiveVar } from 'meteor/reactive-var';
import { Tracker } from 'meteor/tracker';
import { TAPi18n } from 'meteor/tap:i18n';
import { isRtl } from 'meteor/rocketchat:utils';
import { settings } from 'meteor/rocketchat:settings';
import { Users } from 'meteor/rocketchat:models';
import moment from 'moment';

const currentLanguage = new ReactiveVar();
Expand Down Expand Up @@ -66,11 +68,11 @@ Meteor.startup(() => {
};
window.setLanguage = setLanguage;

const defaultUserLanguage = () => RocketChat.settings.get('Language') || getBrowserLanguage() || 'en';
const defaultUserLanguage = () => settings.get('Language') || getBrowserLanguage() || 'en';
window.defaultUserLanguage = defaultUserLanguage;

Tracker.autorun(() => {
const user = RocketChat.models.Users.findOne(Meteor.userId(), { fields: { language: 1 } });
const user = Users.findOne(Meteor.userId(), { fields: { language: 1 } });

setLanguage((user && user.language) || defaultUserLanguage());
});
Expand Down
13 changes: 8 additions & 5 deletions client/startup/startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { Tracker } from 'meteor/tracker';
import { Session } from 'meteor/session';
import { TimeSync } from 'meteor/mizzao:timesync';
import { UserPresence } from 'meteor/konecty:user-presence';
import { fireGlobalEvent } from 'meteor/rocketchat:ui';
import { fireGlobalEvent } from 'meteor/rocketchat:ui-utils';
import { settings } from 'meteor/rocketchat:settings';
import { Users } from 'meteor/rocketchat:models';
import { getUserPreference } from 'meteor/rocketchat:utils';
import toastr from 'toastr';
import hljs from 'highlight.js';
import 'highlight.js/styles/github.css';
Expand All @@ -26,7 +29,7 @@ Meteor.startup(function() {
window.lastMessageWindowHistory = {};

Tracker.autorun(function(computation) {
if (!Meteor.userId() && !RocketChat.settings.get('Accounts_AllowAnonymousRead')) {
if (!Meteor.userId() && !settings.get('Accounts_AllowAnonymousRead')) {
return;
}
Meteor.subscribe('userData');
Expand All @@ -39,7 +42,7 @@ Meteor.startup(function() {
if (!Meteor.userId()) {
return;
}
const user = RocketChat.models.Users.findOne(Meteor.userId(), {
const user = Users.findOne(Meteor.userId(), {
fields: {
status: 1,
'settings.preferences.idleTimeLimit': 1,
Expand All @@ -51,8 +54,8 @@ Meteor.startup(function() {
return;
}

if (RocketChat.getUserPreference(user, 'enableAutoAway')) {
const idleTimeLimit = RocketChat.getUserPreference(user, 'idleTimeLimit') || 300;
if (getUserPreference(user, 'enableAutoAway')) {
const idleTimeLimit = getUserPreference(user, 'idleTimeLimit') || 300;
UserPresence.awayTime = idleTimeLimit * 1000;
} else {
delete UserPresence.awayTime;
Expand Down
6 changes: 4 additions & 2 deletions client/startup/unread.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { Session } from 'meteor/session';
import { Favico } from 'meteor/rocketchat:favico';
import { ChatSubscription } from 'meteor/rocketchat:models';
import { RoomManager, menu, fireGlobalEvent, readMessage } from 'meteor/rocketchat:ui-utils';
import { getUserPreference } from 'meteor/rocketchat:utils';
import { settings } from 'meteor/rocketchat:settings';

Meteor.startup(function() {
Tracker.autorun(function() {
Expand Down Expand Up @@ -38,7 +40,7 @@ Meteor.startup(function() {
// Increment the total unread count.
unreadCount += subscription.unread;
if (subscription.alert === true && subscription.unreadAlert !== 'nothing') {
const userUnreadAlert = RocketChat.getUserPreference(Meteor.userId(), 'unreadAlert');
const userUnreadAlert = getUserPreference(Meteor.userId(), 'unreadAlert');
if (subscription.unreadAlert === 'all' || userUnreadAlert !== false) {
unreadAlert = '•';
}
Expand Down Expand Up @@ -73,7 +75,7 @@ Meteor.startup(function() {
});

Tracker.autorun(function() {
const siteName = RocketChat.settings.get('Site_Name') || '';
const siteName = settings.get('Site_Name') || '';

const unread = Session.get('unread');
fireGlobalEvent('unread-changed', unread);
Expand Down
3 changes: 2 additions & 1 deletion client/startup/userSetUtcOffset.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';
import { Users } from 'meteor/rocketchat:models';
import moment from 'moment';

Meteor.startup(function() {
Tracker.autorun(function() {
const user = RocketChat.models.Users.findOne({ _id: Meteor.userId() }, { fields: { statusConnection: 1, utcOffset: 1 } });
const user = Users.findOne({ _id: Meteor.userId() }, { fields: { statusConnection: 1, utcOffset: 1 } });
if (user && user.statusConnection === 'online') {
const utcOffset = moment().utcOffset() / 60;
if (user.utcOffset !== utcOffset) {
Expand Down
3 changes: 2 additions & 1 deletion imports/message-read-receipt/client/main.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Template } from 'meteor/templating';
import { settings } from 'meteor/rocketchat:settings';

Template.main.helpers({
readReceiptsEnabled() {
if (RocketChat.settings.get('Message_Read_Receipt_Store_Users')) {
if (settings.get('Message_Read_Receipt_Store_Users')) {
return 'read-receipts-enabled';
}
},
Expand Down
3 changes: 2 additions & 1 deletion imports/message-read-receipt/client/message.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Template } from 'meteor/templating';
import { settings } from 'meteor/rocketchat:settings';

Template.message.helpers({
readReceipt() {
if (!RocketChat.settings.get('Message_Read_Receipt_Enabled')) {
if (!settings.get('Message_Read_Receipt_Enabled')) {
return;
}

Expand Down
3 changes: 2 additions & 1 deletion imports/message-read-receipt/client/readReceipts.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import { Template } from 'meteor/templating';
import { settings } from 'meteor/rocketchat:settings';
import moment from 'moment';

import './readReceipts.css';
Expand All @@ -11,7 +12,7 @@ Template.readReceipts.helpers({
return Template.instance().readReceipts.get();
},
displayName() {
return (RocketChat.settings.get('UI_Use_Real_Name') && this.user.name) || this.user.username;
return (settings.get('UI_Use_Real_Name') && this.user.name) || this.user.username;
},
time() {
return moment(this.ts).format('L LTS');
Expand Down
Loading

0 comments on commit 0e6ff28

Please sign in to comment.