Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into fix/…
Browse files Browse the repository at this point in the history
…pinned_messages_collapse

* 'develop' of github.com:RocketChat/Rocket.Chat:
  [NEW] Check the Omnichannel service status per Department (#16425)
  [IMPROVE] Show more information related to the Omnichannel room closing data (#16414)
  Fix index creation for apps_logs collection (#16401)
  Revert message properties validation (#16395)
  [FIX] Rooms not being marked as read sometimes (#16397)
  Update apps engine to 1.12.0-beta.2496 (#16398)
  [FIX] Container heights (#16388)
  Regression: App deletion wasn’t returning the correct information (#16360)
  [BREAK] Remove deprecated publications (#16351)
  • Loading branch information
gabriellsh committed Feb 3, 2020
2 parents c1b03a2 + 1c9441c commit f0ca4b6
Show file tree
Hide file tree
Showing 96 changed files with 194 additions and 1,840 deletions.
2 changes: 1 addition & 1 deletion app/api/server/v1/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { settings } from '../../../settings/server';
import { API } from '../api';
import { getDefaultUserFields } from '../../../utils/server/functions/getDefaultUserFields';
import { getURL } from '../../../utils/lib/getURL';
import { StdOut } from '../../../logger/server/publish';
import { StdOut } from '../../../logger/server/streamer';


// DEPRECATED
Expand Down
4 changes: 2 additions & 2 deletions app/apps/server/bridges/livechat.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export class AppLivechatBridge {
this.orch = orch;
}

isOnline() {
return Livechat.online();
isOnline(department) {
return Livechat.online(department);
}

async createMessage(message, appId) {
Expand Down
2 changes: 1 addition & 1 deletion app/apps/server/bridges/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class AppMessageBridge {

const convertedMessage = this.orch.getConverters().get('messages').convertAppMessage(message);

const sentMessage = executeSendMessage(convertedMessage.u._id, convertedMessage, true);
const sentMessage = executeSendMessage(convertedMessage.u._id, convertedMessage);

return sentMessage._id;
}
Expand Down
14 changes: 6 additions & 8 deletions app/apps/server/communication/rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,14 +461,12 @@ export class AppsRestApi {
return API.v1.notFound(`No App found by the id of: ${ this.urlParams.id }`);
}

manager.remove(prl.getID())
.then(() => {
const info = prl.getInfo();
info.status = prl.getStatus();

API.v1.success({ app: info });
})
.catch((err) => API.v1.failure(err));
Promise.await(manager.remove(prl.getID()));

const info = prl.getInfo();
info.status = prl.getStatus();

return API.v1.success({ app: info });
},
});

Expand Down
3 changes: 1 addition & 2 deletions app/authorization/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ import './methods/deleteRole';
import './methods/removeRoleFromPermission';
import './methods/removeUserFromRole';
import './methods/saveRole';
import './publications/permissions';
import './publications/roles';
import './streamer/permissions';
import './startup';

export {
Expand Down
21 changes: 0 additions & 21 deletions app/authorization/server/publications/roles.js

This file was deleted.

9 changes: 9 additions & 0 deletions app/authorization/server/startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Meteor } from 'meteor/meteor';
import { Roles, Permissions, Settings } from '../../models';
import { settings } from '../../settings/server';
import { getSettingPermissionId, CONSTANTS } from '../lib';
import { clearCache } from './functions/hasPermission';

Meteor.startup(function() {
// Note:
Expand Down Expand Up @@ -208,4 +209,12 @@ Meteor.startup(function() {
};

settings.onload('*', createPermissionForAddedSetting);

Roles.on('change', ({ diff }) => {
if (diff && Object.keys(diff).length === 1 && diff._updatedAt) {
// avoid useless changes
return;
}
clearCache();
});
});
1 change: 0 additions & 1 deletion app/custom-sounds/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ import './methods/deleteCustomSound';
import './methods/insertOrUpdateSound';
import './methods/listCustomSounds';
import './methods/uploadCustomSound';
import './publications/customSounds';
31 changes: 0 additions & 31 deletions app/custom-sounds/server/publications/customSounds.js

This file was deleted.

2 changes: 0 additions & 2 deletions app/discussion/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import './authorization';
import './permissions';

import './hooks/propagateDiscussionMetadata';
import './publications/discussionParentAutocomplete';
import './publications/discussionsOfRoom';

// Methods
import './methods/createDiscussion';
Expand Down
45 changes: 0 additions & 45 deletions app/discussion/server/publications/discussionParentAutocomplete.js

This file was deleted.

33 changes: 0 additions & 33 deletions app/discussion/server/publications/discussionsOfRoom.js

This file was deleted.

1 change: 0 additions & 1 deletion app/emoji-custom/server/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import './startup/emoji-custom';
import './startup/settings';
import './publications/fullEmojiData';
import './methods/listEmojiCustom';
import './methods/deleteEmojiCustom';
import './methods/insertOrUpdateEmoji';
Expand Down
32 changes: 0 additions & 32 deletions app/emoji-custom/server/publications/fullEmojiData.js

This file was deleted.

2 changes: 0 additions & 2 deletions app/integrations/server/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import '../lib/rocketchat';
import './logger';
import './lib/validation';
import './publications/integrations';
import './publications/integrationHistory';
import './methods/incoming/addIncomingIntegration';
import './methods/incoming/updateIncomingIntegration';
import './methods/incoming/deleteIncomingIntegration';
Expand Down
20 changes: 0 additions & 20 deletions app/integrations/server/publications/integrationHistory.js

This file was deleted.

23 changes: 0 additions & 23 deletions app/integrations/server/publications/integrations.js

This file was deleted.

30 changes: 2 additions & 28 deletions app/lib/server/functions/sendMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { Apps } from '../../../apps/server';
import { Markdown } from '../../../markdown/server';
import { isURL, isRelativeURL } from '../../../utils/lib/isURL';
import { FileUpload } from '../../../file-upload/server';
import { Users } from '../../../models/server';

/**
* IMPORTANT
Expand Down Expand Up @@ -144,42 +143,17 @@ const validateMessage = (message) => {
}
};

const validateUserIdentity = (message, _id) => {
if (!message.alias && !message.avatar) {
return;
}
const forbiddenPropsToChangeWhenUserIsNotABot = ['avatar'];
const user = Users.findOneById(_id, { fields: { roles: 1, name: 1 } });
/**
* If the query returns no user, the message has likely
* been sent by a Livechat Visitor, so we don't need to
* validate whether the sender is a bot.
*/
if (!user) {
return;
}
const userIsNotABot = !user.roles.includes('bot');
const messageContainsAnyForbiddenProp = Object.keys(message).some((key) => forbiddenPropsToChangeWhenUserIsNotABot.includes(key));
if (userIsNotABot && (messageContainsAnyForbiddenProp || (typeof message.alias !== 'undefined' && message.alias !== user.name))) {
throw new Error('You are not authorized to change message properties');
}
};

export const sendMessage = function(user, message, room, upsert = false, trustedSender = false) {
export const sendMessage = function(user, message, room, upsert = false) {
if (!user || !message || !room._id) {
return false;
}
const { _id, username, name } = user;

if (!trustedSender) {
validateUserIdentity(message, _id);
}

validateMessage(message);

if (!message.ts) {
message.ts = new Date();
}
const { _id, username, name } = user;
message.u = {
_id,
username,
Expand Down
4 changes: 2 additions & 2 deletions app/lib/server/methods/sendMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { RateLimiter } from '../lib';
import { canSendMessage } from '../../../authorization/server';
import { SystemLogger } from '../../../logger/server';

export function executeSendMessage(uid, message, trustedSender = false) {
export function executeSendMessage(uid, message) {
if (message.tmid && !settings.get('Threads_enabled')) {
throw new Meteor.Error('error-not-allowed', 'not-allowed', {
method: 'sendMessage',
Expand Down Expand Up @@ -73,7 +73,7 @@ export function executeSendMessage(uid, message, trustedSender = false) {
}

metrics.messagesSent.inc(); // TODO This line needs to be moved to it's proper place. See the comments on: https://github.com/RocketChat/Rocket.Chat/pull/5736
return sendMessage(user, message, room, false, trustedSender);
return sendMessage(user, message, room, false);
} catch (error) {
if (error === 'error-not-allowed') {
throw new Meteor.Error('error-not-allowed');
Expand Down
Loading

0 comments on commit f0ca4b6

Please sign in to comment.