prevent viewers seeing other viewers when hidden from userlist

This commit is contained in:
KDSBrowne 2019-09-11 16:43:11 +00:00
parent 970a85a095
commit dc1dd17d8a
2 changed files with 18 additions and 8 deletions

View File

@ -22,6 +22,7 @@ export default function startTyping(meetingId, userId, chatId) {
userId,
name: user.name,
isTypingTo: chatId,
role: user.role,
time: (new Date()),
};

View File

@ -3,6 +3,7 @@ import { withTracker } from 'meteor/react-meteor-data';
import Auth from '/imports/ui/services/auth';
import { UsersTyping } from '/imports/api/group-chat-msg';
import Users from '/imports/api/users';
import Meetings from '/imports/api/meetings';
import TypingIndicator from './component';
const CHAT_CONFIG = Meteor.settings.public.chat;
@ -19,31 +20,39 @@ class TypingIndicatorContainer extends PureComponent {
export default withTracker(() => {
const idChatOpen = Session.get('idChatOpen');
const meeting = Meetings.findOne({ meetingId: Auth.meetingID }, {
fields: {
'lockSettingsProps.hideUserList': 1,
},
});
let selector = {
const selector = {
meetingId: Auth.meetingID,
isTypingTo: PUBLIC_CHAT_KEY,
};
if (idChatOpen !== PUBLIC_CHAT_KEY) {
selector = {
meetingId: Auth.meetingID,
isTypingTo: Auth.userID,
userId: idChatOpen,
};
selector.isTypingTo = Auth.userID;
selector.userId = idChatOpen;
}
const typingUsers = UsersTyping.find(selector).fetch();
const currentUser = Users.findOne({
meetingId: Auth.meetingID,
userId: Auth.userID,
}, {
fields: {
userId: 1,
role: 1,
},
});
if (meeting.lockSettingsProps.hideUserList && currentUser.role === 'VIEWER') {
selector.role = { $ne: 'VIEWER' };
}
const typingUsers = UsersTyping.find(selector).fetch();
return {
currentUserId: currentUser ? currentUser.userId : null,
typingUsers,