From e1004b64d300300829569473ade45db8581c3606 Mon Sep 17 00:00:00 2001 From: Klaus Date: Wed, 12 Jul 2017 10:54:54 -0300 Subject: [PATCH] Filtering correct the messages --- .../imports/api/2.0/chat/server/publishers.js | 9 +++------ .../imports/ui/components/chat/service.js | 13 +++++-------- .../imports/ui/services/unread-messages/index.js | 13 ++++++------- 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/bigbluebutton-html5/imports/api/2.0/chat/server/publishers.js b/bigbluebutton-html5/imports/api/2.0/chat/server/publishers.js index b005e9e845..c6e8d666ce 100644 --- a/bigbluebutton-html5/imports/api/2.0/chat/server/publishers.js +++ b/bigbluebutton-html5/imports/api/2.0/chat/server/publishers.js @@ -6,9 +6,6 @@ import Logger from '/imports/startup/server/logger'; import mapToAcl from '/imports/startup/mapToAcl'; function chat(credentials) { - const CHAT_CONFIG = Meteor.settings.public.chat; - const PUBLIC_CHAT_TYPE = CHAT_CONFIG.type_public; - const { meetingId, requesterUserId, requesterToken } = credentials; check(meetingId, String); @@ -20,13 +17,13 @@ function chat(credentials) { return Chat.find({ $or: [ { - 'message.chatType': PUBLIC_CHAT_TYPE, + 'message.toUsername': 'public_chat_username', meetingId, }, { - 'message.fromUserid': requesterUserId, + 'message.fromUserId': requesterUserId, meetingId, }, { - 'message.toUserid': requesterUserId, + 'message.toUserId': requesterUserId, meetingId, }, ], diff --git a/bigbluebutton-html5/imports/ui/components/chat/service.js b/bigbluebutton-html5/imports/ui/components/chat/service.js index 5dc7a35bf9..e7aebefdbc 100644 --- a/bigbluebutton-html5/imports/ui/components/chat/service.js +++ b/bigbluebutton-html5/imports/ui/components/chat/service.js @@ -12,8 +12,6 @@ const CHAT_CONFIG = Meteor.settings.public.chat; const GROUPING_MESSAGES_WINDOW = CHAT_CONFIG.grouping_messages_window; const SYSTEM_CHAT_TYPE = CHAT_CONFIG.type_system; -const PUBLIC_CHAT_TYPE = CHAT_CONFIG.type_public; -const PRIVATE_CHAT_TYPE = CHAT_CONFIG.type_private; const PUBLIC_CHAT_ID = CHAT_CONFIG.public_id; const PUBLIC_CHAT_USERID = CHAT_CONFIG.public_userid; @@ -105,11 +103,10 @@ const reduceMessages = (previous, current) => { const getPublicMessages = () => { const publicMessages = Chats.find({ - 'message.chatType': { $in: [PUBLIC_CHAT_TYPE, SYSTEM_CHAT_TYPE] }, + 'message.toUsername': { $in: ['public_chat_username', SYSTEM_CHAT_TYPE] }, }, { sort: ['message.fromTime'], - }) - .fetch(); + }).fetch(); return publicMessages .reduce(reduceMessages, []) @@ -118,10 +115,10 @@ const getPublicMessages = () => { const getPrivateMessages = (userID) => { const messages = Chats.find({ - 'message.chatType': PRIVATE_CHAT_TYPE, + 'message.toUsername': { $ne: 'public_chat_username' }, $or: [ - { 'message.toUserid': userID }, - { 'message.fromUserid': userID }, + { 'message.toUserId': userID }, + { 'message.fromUserId': userID }, ], }, { sort: ['message.fromTime'], diff --git a/bigbluebutton-html5/imports/ui/services/unread-messages/index.js b/bigbluebutton-html5/imports/ui/services/unread-messages/index.js index 330d582a75..5767acdd83 100755 --- a/bigbluebutton-html5/imports/ui/services/unread-messages/index.js +++ b/bigbluebutton-html5/imports/ui/services/unread-messages/index.js @@ -5,7 +5,6 @@ import Auth from '/imports/ui/services/auth'; import Chats from '/imports/api/2.0/chat'; const CHAT_CONFIG = Meteor.settings.public.chat; -const PUBLIC_CHAT_USERID = CHAT_CONFIG.public_userid; const STORAGE_KEY = CHAT_CONFIG.storage_key; class UnreadMessagesTracker { @@ -32,18 +31,18 @@ class UnreadMessagesTracker { count(chatID) { const filter = { - 'message.from_time': { + 'message.fromTime': { $gt: this.get(chatID), }, - 'message.from_userid': { $ne: Auth.userID }, + 'message.fromUserId': { $ne: Auth.userID }, }; // Minimongo does not support $eq. See https://github.com/meteor/meteor/issues/4142 - if (chatID === PUBLIC_CHAT_USERID) { - filter['message.to_userid'] = { $not: { $ne: chatID } }; + if (chatID === 'public_chat_userid') { + filter['message.toUserId'] = { $not: { $ne: chatID } }; } else { - filter['message.to_userid'] = { $not: { $ne: Auth.userID } }; - filter['message.from_userid'].$not = { $ne: chatID }; + filter['message.toUserId'] = { $not: { $ne: Auth.userID } }; + filter['message.fromUserId'].$not = { $ne: chatID }; } return Chats.find(filter).count();