Merge pull request #5386 from jfsiebel/fix-direct-message-problem

Fix private chat messages
This commit is contained in:
Anton Georgiev 2018-04-25 11:18:37 -04:00 committed by GitHub
commit 768a8733eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,5 @@
import WhiteboardMultiUser from '/imports/api/whiteboard-multi-user/';
import Users from '/imports/api/users';
const MSG_DIRECT_TYPE = 'DIRECT';
const NODE_USER = 'nodeJSapp';
@ -16,8 +17,16 @@ export const indexOf = [].indexOf || function (item) {
export const processForHTML5ServerOnly = fn => (message, ...args) => {
const { envelope } = message;
const { routing } = envelope;
const { msgType, meetingId, userId } = routing;
const shouldSkip = routing.msgType === MSG_DIRECT_TYPE && routing.userId !== NODE_USER;
const selector = {
userId,
meetingId,
};
const user = Users.findOne(selector);
const shouldSkip = user && msgType === MSG_DIRECT_TYPE && userId !== NODE_USER && user.clientType !== 'HTML5';
if (shouldSkip) return () => { };
return fn(message, ...args);
};