added "fields:{...}", removed most mapUser

This commit is contained in:
Anton Georgiev 2019-08-22 08:05:06 -04:00
parent e8ec7129b3
commit 892336632f
33 changed files with 186 additions and 178 deletions

View File

@ -6,7 +6,9 @@ import setConnectionStatus from '/imports/api/users/server/modifiers/setConnecti
import Users from '/imports/api/users/';
import Logger from '/imports/startup/server/logger';
export default function handleMeetingEnd({ body }, meetingId) {
export default function handleMeetingEnd({ body }) {
check(body, Object);
const { meetingId } = body;
check(meetingId, String);
const cb = (err, num, meetingType) => {
@ -15,7 +17,7 @@ export default function handleMeetingEnd({ body }, meetingId) {
return;
}
if (num) {
Users.find({ meetingId })
Users.find({ meetingId }, { fields: { meetingId: 1, userId: 1 } })
.fetch().map(user => setConnectionStatus(user.meetingId, user.userId, 'offline'));
Meteor.setTimeout(() => { meetingHasEnded(meetingId); }, 10000);
}

View File

@ -23,7 +23,7 @@ export default function addPoll(meetingId, requesterId, poll) {
clientType: { $ne: 'dial-in-user' },
};
const userIds = Users.find(userSelector)
const userIds = Users.find(userSelector, { fields: { userId: 1 } })
.fetch()
.map(user => user.userId);

View File

@ -15,7 +15,7 @@ export default function handleSyncGetPresentationPods({ body }, meetingId) {
const presentationPodsToRemove = PresentationPods.find({
meetingId,
podId: { $nin: presentationPodIds },
}).fetch();
}, { fields: { podId: 1 } }).fetch();
presentationPodsToRemove.forEach(p => removePresentationPod(meetingId, p.podId));

View File

@ -12,7 +12,7 @@ export default function clearSlidesPresentation(meetingId, presentationId) {
presentationId,
};
const whiteboardIds = Slides.find(selector).map(row => row.id);
const whiteboardIds = Slides.find(selector, { fields: { id: 1 } }).map(row => row.id);
const cb = (err) => {
if (err) {

View File

@ -14,7 +14,7 @@ export default function handleGetUsers({ body }, meetingId) {
const usersToRemove = Users.find({
meetingId,
userId: { $nin: usersIds },
}).fetch();
}, { fields: { userId: 1 } }).fetch();
usersToRemove.forEach(user => removeUser(meetingId, user.userId));

View File

@ -11,17 +11,17 @@ export default function handleGetVoiceUsers({ body }, meetingId) {
check(meetingId, String);
check(users, Array);
const meeting = Meetings.findOne({ meetingId: meetingId });
const meeting = Meetings.findOne({ meetingId }, { fields: { 'voiceProp.voiceConf': 1 } });
const usersIds = users.map(m => m.intId);
const voiceUsersIdsToUpdate = VoiceUsers.find({
meetingId,
intId: { $in: usersIds },
}).fetch().map(m => m.intId);;
}, { fields: { intId: 1 } }).fetch().map(m => m.intId);
let voiceUsersUpdated = [];
users.forEach(user => {
if(voiceUsersIdsToUpdate.indexOf(user.intId) >= 0) {
const voiceUsersUpdated = [];
users.forEach((user) => {
if (voiceUsersIdsToUpdate.indexOf(user.intId) >= 0) {
// user already exist, then update
voiceUsersUpdated.push(updateVoiceUser(meetingId, {
intId: user.intId,
@ -29,7 +29,7 @@ export default function handleGetVoiceUsers({ body }, meetingId) {
talking: user.talking,
muted: user.muted,
voiceConf: meeting.voiceProp.voiceConf,
joined: true
joined: true,
}));
} else {
// user doesn't exist yet, then add it
@ -43,7 +43,7 @@ export default function handleGetVoiceUsers({ body }, meetingId) {
callingWith: user.callingWith,
listenOnly: user.listenOnly,
voiceConf: meeting.voiceProp.voiceConf,
joined: true
joined: true,
});
}
});
@ -56,7 +56,7 @@ export default function handleGetVoiceUsers({ body }, meetingId) {
voiceUsersToRemove.forEach(user => removeVoiceUser(meetingId, {
voiceConf: meeting.voiceProp.voiceConf,
voiceUserId: user.voiceUserId,
intId: user.intId
intId: user.intId,
}));
return voiceUsersUpdated;

View File

@ -1,4 +1,3 @@
import { check } from 'meteor/check';
import VoiceUsers from '/imports/api/voice-users/';
import Meetings from '/imports/api/meetings';
import addDialInUser from '/imports/api/users/server/modifiers/addDialInUser';
@ -11,13 +10,13 @@ export default function handleVoiceUsers({ header, body }) {
const { voiceUsers } = body;
const { meetingId } = header;
const meeting = Meetings.findOne({ meetingId });
const meeting = Meetings.findOne({ meetingId }, { fields: { 'voiceProp.voiceConf': 1 } });
const usersIds = voiceUsers.map(m => m.intId);
const voiceUsersIdsToUpdate = VoiceUsers.find({
meetingId,
intId: { $in: usersIds },
}).fetch().map(m => m.intId);
}, { fields: { intId: 1 } }).fetch().map(m => m.intId);
const voiceUsersUpdated = [];
voiceUsers.forEach((voice) => {
@ -54,7 +53,7 @@ export default function handleVoiceUsers({ header, body }) {
const voiceUsersToRemove = VoiceUsers.find({
meetingId,
intId: { $nin: usersIds },
}).fetch();
}, { fields: { voiceUserId: 1, intId: 1 } }).fetch();
voiceUsersToRemove.forEach(user => removeVoiceUser(meetingId, {
voiceConf: meeting.voiceProp.voiceConf,
voiceUserId: user.voiceUserId,

View File

@ -24,14 +24,25 @@ const getUsersNotAssigned = filterBreakoutUsers(currentBreakoutUsers);
const takePresenterRole = () => makeCall('assignPresenter', Auth.userID);
export default {
isUserPresenter: () => Users.findOne({ userId: Auth.userID }).presenter,
isUserModerator: () => Users.findOne({ userId: Auth.userID }).role === ROLE_MODERATOR,
meetingIsBreakout: () => Meetings.findOne({ meetingId: Auth.meetingID }).meetingProp.isBreakout,
meetingName: () => Meetings.findOne({ meetingId: Auth.meetingID }).meetingProp.name,
users: () => Users.find({ connectionStatus: 'online', meetingId: Auth.meetingID, clientType: { $ne: DIAL_IN_USER } }).fetch(),
hasBreakoutRoom: () => Breakouts.find({ parentMeetingId: Auth.meetingID }).fetch().length > 0,
isBreakoutEnabled: () => Meetings.findOne({ meetingId: Auth.meetingID }).breakoutProps.enabled,
isBreakoutRecordable: () => Meetings.findOne({ meetingId: Auth.meetingID }).breakoutProps.record,
isUserPresenter: () => Users.findOne({ userId: Auth.userID },
{ fields: { presenter: 1 } }).presenter,
isUserModerator: () => Users.findOne({ userId: Auth.userID },
{ fields: { role: 1 } }).role === ROLE_MODERATOR,
meetingIsBreakout: () => Meetings.findOne({ meetingId: Auth.meetingID },
{ fields: { 'meetingProp.isBreakout': 1 } }).meetingProp.isBreakout,
meetingName: () => Meetings.findOne({ meetingId: Auth.meetingID },
{ fields: { 'meetingProp.name': 1 } }).meetingProp.name,
users: () => Users.find({
connectionStatus: 'online',
meetingId: Auth.meetingID,
clientType: { $ne: DIAL_IN_USER },
}).fetch(),
hasBreakoutRoom: () => Breakouts.find({ parentMeetingId: Auth.meetingID },
{ fields: {} }).count() > 0,
isBreakoutEnabled: () => Meetings.findOne({ meetingId: Auth.meetingID },
{ fields: { 'breakoutProps.enabled': 1 } }).breakoutProps.enabled,
isBreakoutRecordable: () => Meetings.findOne({ meetingId: Auth.meetingID },
{ fields: { 'breakoutProps.record': 1 } }).breakoutProps.record,
toggleRecording: () => makeCall('toggleRecording'),
createBreakoutRoom: (numberOfRooms, durationInMinutes, record = false) => makeCall('createBreakoutRoom', numberOfRooms, durationInMinutes, record),
sendInvitation: (breakoutId, userId) => makeCall('requestJoinURL', { breakoutId, userId }),

View File

@ -12,7 +12,6 @@ import getFromUserSettings from '/imports/ui/services/users-settings';
import deviceInfo from '/imports/utils/deviceInfo';
import UserInfos from '/imports/api/users-infos';
import { startBandwidthMonitoring, updateNavigatorConnection } from '/imports/ui/services/network-information/index';
import mapUser from '../../services/user/mapUser';
import {
getFontSize,
@ -70,8 +69,9 @@ const AppContainer = (props) => {
};
export default injectIntl(withModalMounter(withTracker(({ intl, baseControls }) => {
const currentUser = Users.findOne({ userId: Auth.userID });
const currentMeeting = Meetings.findOne({ meetingId: Auth.meetingID });
const currentUser = Users.findOne({ userId: Auth.userID }, { fields: { approved: 1, emoji: 1 } });
const currentMeeting = Meetings.findOne({ meetingId: Auth.meetingID },
{ fields: { publishedPoll: 1, voiceProp: 1 } });
const { publishedPoll, voiceProp } = currentMeeting;
if (!currentUser.approved) {
@ -94,6 +94,14 @@ export default injectIntl(withModalMounter(withTracker(({ intl, baseControls })
requesterUserId: Auth.userID,
}).fetch();
const currentUserEmoji = () => (currentUser ? {
status: currentUser.emoji,
changedAt: currentUser.emojiTime,
} : {
status: 'none',
changedAt: null,
});
return {
captions: CaptionsService.isCaptionsActive() ? <CaptionsContainer /> : null,
fontSize: getFontSize(),
@ -107,7 +115,7 @@ export default injectIntl(withModalMounter(withTracker(({ intl, baseControls })
isPhone: deviceInfo.type().isPhone,
isRTL: document.documentElement.getAttribute('dir') === 'rtl',
meetingMuted: voiceProp.muteOnStart,
currentUserEmoji: mapUser(currentUser).emoji,
currentUserEmoji,
hasPublishedPoll: publishedPoll,
startBandwidthMonitoring,
handleNetworkConnection: () => updateNavigatorConnection(navigator.connection),

View File

@ -3,11 +3,6 @@ import Meetings from '/imports/api/meetings';
import Settings from '/imports/ui/services/settings';
import Auth from '/imports/ui/services/auth/index';
const getCaptionsStatus = () => {
const ccSettings = Settings.cc;
return ccSettings ? ccSettings.enabled : false;
};
const getFontSize = () => {
const applicationSettings = Settings.application;
return applicationSettings ? applicationSettings.fontSize : '16px';
@ -15,13 +10,9 @@ const getFontSize = () => {
const getBreakoutRooms = () => Breakouts.find().fetch();
const getMeeting = () => {
const { meetingID } = Auth;
return Meetings.findOne({ meetingId: meetingID });
};
function meetingIsBreakout() {
const meeting = getMeeting();
const meeting = Meetings.findOne({ meetingId: Auth.meetingID },
{ fields: { 'meetingProp.isBreakout': 1 } });
return (meeting && meeting.meetingProp.isBreakout);
}
@ -37,10 +28,8 @@ const validIOSVersion = () => {
};
export {
getCaptionsStatus,
getFontSize,
meetingIsBreakout,
getBreakoutRooms,
getMeeting,
validIOSVersion,
};

View File

@ -62,7 +62,7 @@ class AudioControls extends PureComponent {
listenOnly,
intl,
shortcuts,
currentUserObj,
isVoiceUser,
} = this.props;
let joinIcon = 'audio_off';
@ -76,7 +76,7 @@ class AudioControls extends PureComponent {
return (
<span className={styles.container}>
{showMute && currentUserObj.isVoiceUser
{showMute && isVoiceUser
? (
<Button
className={cx(styles.button, !talking || styles.glow, !muted || styles.btn)}

View File

@ -42,7 +42,7 @@ const handleLeaveAudio = () => {
};
const {
currentUser,
isVoiceUser,
isConnected,
isListenOnly,
isEchoTest,
@ -62,7 +62,7 @@ export default lockContextContainer(withModalMounter(withTracker(({ mountModal,
listenOnly: isConnected() && isListenOnly(),
disable: isConnecting() || isHangingUp() || !Meteor.status().connected,
talking: isTalking() && !isMuted(),
currentUserObj: currentUser(),
isVoiceUser: isVoiceUser(),
handleToggleMuteMicrophone: () => toggleMuteMicrophone(),
handleJoinAudio: () => (isConnected() ? joinListenOnly() : mountModal(<AudioModalContainer />)),
handleLeaveAudio,

View File

@ -2,7 +2,6 @@ import Users from '/imports/api/users';
import Auth from '/imports/ui/services/auth';
import AudioManager from '/imports/ui/services/audio-manager';
import Meetings from '/imports/api/meetings';
import mapUser from '/imports/ui/services/user/mapUser';
import { makeCall } from '/imports/ui/services/api';
import VoiceUsers from '/imports/api/voice-users';
import logger from '/imports/startup/client/logger';
@ -15,9 +14,9 @@ const init = (messages, intl) => {
const meetingId = Auth.meetingID;
const userId = Auth.userID;
const { sessionToken } = Auth;
const User = Users.findOne({ userId });
const User = Users.findOne({ userId }, { fields: { name: 1 } });
const username = User.name;
const Meeting = Meetings.findOne({ meetingId: User.meetingId });
const Meeting = Meetings.findOne({ meetingId: Auth.meetingID }, { fields: { 'voiceProp.voiceConf': 1 } });
const voiceBridge = Meeting.voiceProp.voiceConf;
// FIX ME
@ -35,7 +34,11 @@ const init = (messages, intl) => {
AudioManager.init(userData);
};
const currentUser = () => mapUser(Users.findOne({ intId: Auth.userID }));
const isVoiceUser = () => {
const voiceUser = VoiceUsers.findOne({ intId: Auth.userID },
{ fields: { joined: 1 } });
return voiceUser ? voiceUser.joined : false;
};
const toggleMuteMicrophone = () => {
const userIsMuted = VoiceUsers.findOne({
@ -80,7 +83,7 @@ export default {
isEchoTest: () => AudioManager.isEchoTest,
error: () => AudioManager.error,
isUserModerator: () => Users.findOne({ userId: Auth.userID }).role === ROLE_MODERATOR,
currentUser,
isVoiceUser,
autoplayBlocked: () => AudioManager.autoplayBlocked,
handleAllowAutoplay: () => AudioManager.handleAllowAutoplay(),
};

View File

@ -4,9 +4,10 @@ import { makeCall } from '/imports/ui/services/api';
import Auth from '/imports/ui/services/auth';
import { Session } from 'meteor/session';
import Users from '/imports/api/users';
import mapUser from '/imports/ui/services/user/mapUser';
import fp from 'lodash/fp';
const ROLE_MODERATOR = Meteor.settings.public.user.role_moderator;
const findBreakouts = () => {
const BreakoutRooms = Breakouts.find({
parentMeetingId: Auth.meetingID,
@ -50,30 +51,28 @@ const transferToBreakout = (breakoutId) => {
{ 'breakoutProps.parentId': breakoutRoom.parentMeetingId },
{ 'meetingProp.isBreakout': true },
],
});
}, { fields: { meetingId: 1 } });
transferUserToMeeting(Auth.meetingID, breakoutMeeting.meetingId);
};
const isPresenter = () => {
const User = Users.findOne({ intId: Auth.userID });
const mappedUser = mapUser(User);
return mappedUser.isPresenter;
const User = Users.findOne({ intId: Auth.userID }, { fields: { presenter: 1 } });
return User.presenter;
};
const isModerator = () => {
const User = Users.findOne({ intId: Auth.userID });
const mappedUser = mapUser(User);
return mappedUser.isModerator;
const User = Users.findOne({ intId: Auth.userID }, { fields: { role: 1 } });
return User.role === ROLE_MODERATOR;
};
const getUsersByBreakoutId = breakoutId => Users.find({
meetingId: breakoutId,
connectionStatus: 'online',
});
}, { fields: {} });
const getBreakoutByUserId = userId => Breakouts.find({ 'users.userId': userId }).fetch();
const getBreakoutByUser = user => Breakouts.findOne({ users: user });
const getBreakoutByUser = user => Breakouts.findOne({ users: user }, { fields: { breakoutId: 1 } });
const getUsersFromBreakouts = breakoutsArray => breakoutsArray
.map(breakout => breakout.users)

View File

@ -2,7 +2,6 @@ import _ from 'lodash';
import Captions from '/imports/api/captions';
import Users from '/imports/api/users';
import Auth from '/imports/ui/services/auth';
import mapUser from '/imports/ui/services/user/mapUser';
import { makeCall } from '/imports/ui/services/api';
import { Meteor } from 'meteor/meteor';
import { Session } from 'meteor/session';
@ -10,6 +9,7 @@ import { Session } from 'meteor/session';
const CAPTIONS_CONFIG = Meteor.settings.public.captions;
const CAPTIONS = '_captions_';
const LINE_BREAK = '\n';
const ROLE_MODERATOR = Meteor.settings.public.user.role_moderator;
const getActiveCaptions = () => {
const activeCaptions = Session.get('activeCaptions');
@ -17,13 +17,10 @@ const getActiveCaptions = () => {
return activeCaptions;
};
const getCaptions = (locale) => {
const captions = Captions.findOne({
meetingId: Auth.meetingID,
padId: { $regex: `${CAPTIONS}${locale}$` },
});
return captions;
};
const getCaptions = locale => Captions.findOne({
meetingId: Auth.meetingID,
padId: { $regex: `${CAPTIONS}${locale}$` },
});
const getCaptionsData = () => {
const activeCaptions = getActiveCaptions();
@ -45,22 +42,25 @@ const getCaptionsData = () => {
const getAvailableLocales = () => {
const { meetingID } = Auth;
const locales = [];
Captions.find({ meetingId: meetingID }).forEach((caption) => {
if (caption.ownerId === '') {
locales.push(caption.locale);
}
});
Captions.find({ meetingId: meetingID },
{ fields: { ownerId: 1, locale: 1 } })
.forEach((caption) => {
if (caption.ownerId === '') {
locales.push(caption.locale);
}
});
return locales;
};
const getOwnedLocales = () => {
const { meetingID } = Auth;
const locales = [];
Captions.find({ meetingId: meetingID }).forEach((caption) => {
if (caption.ownerId !== '') {
locales.push(caption.locale);
}
});
Captions.find({ meetingId: meetingID }, { fields: { ownerId: 1, locale: 1 } })
.forEach((caption) => {
if (caption.ownerId !== '') {
locales.push(caption.locale);
}
});
return locales;
};
@ -151,10 +151,8 @@ const formatCaptionsText = (text) => {
return filteredText.join(LINE_BREAK);
};
const amIModerator = () => {
const currentUser = Users.findOne({ userId: Auth.userID });
return mapUser(currentUser).isModerator;
};
const amIModerator = () => Users.findOne({ userId: Auth.userID },
{ fields: { role: 1 } }).role === ROLE_MODERATOR;
const getSpeechRecognitionAPI = () => window.SpeechRecognition || window.webkitSpeechRecognition;

View File

@ -57,7 +57,7 @@ export default injectIntl(withTracker(({ intl }) => {
let systemMessageIntl = {};
if (chatID === PUBLIC_CHAT_KEY) {
const { welcomeProp } = ChatService.getMeeting();
const { welcomeProp } = ChatService.getWelcomeProp();
const currentUser = ChatService.getUser(Auth.userID);
messages = ChatService.getPublicGroupMessages();

View File

@ -169,7 +169,8 @@ class MessageForm extends PureComponent {
setMessageState() {
const { chatId, UnsentMessagesCollection } = this.props;
const unsentMessageByChat = UnsentMessagesCollection.findOne({ chatId });
const unsentMessageByChat = UnsentMessagesCollection.findOne({ chatId },
{ fields: { message: 1 } });
this.setState({ message: unsentMessageByChat ? unsentMessageByChat.message : '' });
}

View File

@ -40,7 +40,8 @@ const getUser = (userId) => {
return user;
};
const getMeeting = () => Meetings.findOne({});
const getWelcomeProp = () => Meetings.findOne({ meetingId: Auth.meetingID },
{ fields: { welcomeProp: 1 } });
const mapGroupMessage = (message) => {
const mappedMessage = {
@ -101,6 +102,7 @@ const reduceAndMapGroupMessages = messages => (messages
const getPublicGroupMessages = () => {
const publicGroupMessages = GroupChatMsg.find({
meetingId: Auth.meetingID,
chatId: PUBLIC_GROUP_CHAT_ID,
}, { sort: ['timestamp'] }).fetch();
return publicGroupMessages;
@ -111,9 +113,10 @@ const getPrivateGroupMessages = () => {
const senderId = Auth.userID;
const privateChat = GroupChat.findOne({
meetingId: Auth.meetingID,
users: { $all: [chatID, senderId] },
access: PRIVATE_CHAT_TYPE,
});
}, { fields: { chatId: 1 } });
let messages = [];
@ -123,6 +126,7 @@ const getPrivateGroupMessages = () => {
} = privateChat;
messages = GroupChatMsg.find({
meetingId: Auth.meetingID,
chatId,
}, { sort: ['timestamp'] }).fetch();
}
@ -133,15 +137,17 @@ const getPrivateGroupMessages = () => {
const isChatLocked = (receiverID) => {
const isPublic = receiverID === PUBLIC_CHAT_ID;
const meeting = Meetings.findOne({});
const user = Users.findOne({ userId: Auth.userID });
const meeting = Meetings.findOne({ meetingId: Auth.meetingID },
{ fields: { 'lockSettingsProps.disablePublicChat': 1 } });
const user = Users.findOne({ meetingId: Auth.meetingID, userId: Auth.userID },
{ fields: { locked: 1, role: 1 } });
if (meeting.lockSettingsProps !== undefined) {
if (user.locked && user.role !== ROLE_MODERATOR) {
if (isPublic) {
return meeting.lockSettingsProps.disablePublicChat;
}
const receivingUser = Users.findOne({ userId: receiverID });
const receivingUser = Users.findOne({ userId: receiverID }, { fields: { role: 1 } });
const receiverIsMod = receivingUser && receivingUser.role === ROLE_MODERATOR;
return !receiverIsMod && meeting.lockSettingsProps.disablePrivateChat;
}
@ -174,7 +180,8 @@ const sendGroupMessage = (message) => {
const receiverId = { id: chatID };
if (!isPublicChat) {
const privateChat = GroupChat.findOne({ users: { $all: [chatID, sender.userId] } });
const privateChat = GroupChat.findOne({ users: { $all: [chatID, sender.userId] } },
{ fields: { chatId: 1 } });
if (privateChat) {
const { chatId: privateChatId } = privateChat;
@ -204,7 +211,8 @@ const sendGroupMessage = (message) => {
};
const getScrollPosition = (receiverID) => {
const scroll = ScrollCollection.findOne({ receiver: receiverID }) || { position: null };
const scroll = ScrollCollection.findOne({ receiver: receiverID },
{ fields: { position: 1 } }) || { position: null };
return scroll.position;
};
@ -253,7 +261,7 @@ const htmlDecode = (input) => {
// Export the chat as [Hour:Min] user: message
const exportChat = (messageList) => {
const { welcomeProp } = getMeeting();
const { welcomeProp } = getWelcomeProp();
const { loginTime } = getUser(Auth.userID);
const { welcomeMsg } = welcomeProp;
@ -280,13 +288,13 @@ const exportChat = (messageList) => {
if (message.type === SYSTEM_CHAT_TYPE) {
return `${hourMin} ${message.message}`;
}
const userName = message.sender === PUBLIC_CHAT_USER_ID ? '' : `${getUser(message.sender).name} :`;
const userName = message.sender === PUBLIC_CHAT_USER_ID
? ''
: `${getUser(message.sender).name} :`;
return `${hourMin} ${userName} ${htmlDecode(message.message)}`;
}).join('\n');
};
const getUnreadMessagesFromChatId = chatId => UnreadMessages.getUnreadMessages(chatId);
const getAllMessages = (chatID) => {
const filter = {
sender: { $ne: Auth.userID },
@ -294,7 +302,8 @@ const getAllMessages = (chatID) => {
if (chatID === PUBLIC_GROUP_CHAT_ID) {
filter.chatId = { $eq: chatID };
} else {
const privateChat = GroupChat.findOne({ users: { $all: [chatID, Auth.userID] } });
const privateChat = GroupChat.findOne({ users: { $all: [chatID, Auth.userID] } },
{ fields: { chatId: 1 } });
filter.chatId = { $ne: PUBLIC_GROUP_CHAT_ID };
@ -306,9 +315,6 @@ const getAllMessages = (chatID) => {
return messages;
};
const getlastMessage = lastMessages => lastMessages.sort((a,
b) => a.timestamp - b.timestamp).pop();
const maxTimestampReducer = (max, el) => ((el.timestamp > max) ? el.timestamp : max);
const maxNumberReducer = (max, el) => ((el > max) ? el : max);
@ -323,7 +329,7 @@ export default {
getPublicGroupMessages,
getPrivateGroupMessages,
getUser,
getMeeting,
getWelcomeProp,
getScrollPosition,
hasUnreadMessages,
lastReadMessageTime,
@ -335,11 +341,7 @@ export default {
removeFromClosedChatsSession,
exportChat,
clearPublicChatHistory,
getlastMessage,
getUnreadMessagesFromChatId,
getAllMessages,
maxTimestampReducer,
maxNumberReducer,
getLastMessageTimestampFromChatList,
UnsentMessagesCollection,
};

View File

@ -26,7 +26,7 @@ export default withTracker(() => {
const meetingId = Auth.meetingID;
const meetingObject = Meetings.findOne({
meetingId,
});
}, { fields: { 'meetingProp.name': 1 } });
if (meetingObject != null) {
meetingTitle = meetingObject.meetingProp.name;
@ -43,7 +43,7 @@ export default withTracker(() => {
const currentUserId = Auth.userID;
const { connectRecordingObserver, processOutsideToggleRecording } = Service;
const currentUser = Users.findOne({ userId: Auth.userID });
const currentUser = Users.findOne({ userId: Auth.userID }, { fields: { role: 1 } });
const openPanel = Session.get('openPanel');
const isExpanded = openPanel !== '';
const amIModerator = currentUser.role === ROLE_MODERATOR;

View File

@ -3,18 +3,17 @@ import Meetings from '/imports/api/meetings';
import Note from '/imports/api/note';
import Auth from '/imports/ui/services/auth';
import Settings from '/imports/ui/services/settings';
import mapUser from '/imports/ui/services/user/mapUser';
import { Session } from 'meteor/session';
const NOTE_CONFIG = Meteor.settings.public.note;
const getNoteId = () => {
const note = Note.findOne({ meetingId: Auth.meetingID });
const note = Note.findOne({ meetingId: Auth.meetingID }, { fields: { noteId: 1 } });
return note ? note.noteId : '';
};
const getReadOnlyNoteId = () => {
const note = Note.findOne({ meetingId: Auth.meetingID });
const note = Note.findOne({ meetingId: Auth.meetingID }, { fields: { readOnlyNoteId: 1 } });
return note ? note.readOnlyNoteId : '';
};
@ -23,14 +22,9 @@ const getLang = () => {
return locale ? locale.toLowerCase() : '';
};
const getCurrentUser = () => {
const User = Users.findOne({ userId: Auth.userID });
return User;
};
const getNoteParams = () => {
const { config } = NOTE_CONFIG;
const User = getCurrentUser();
const User = Users.findOne({ userId: Auth.userID }, { fields: { name: 1, color: 1 } });
config.userName = User.name;
config.userColor = User.color;
config.lang = getLang();
@ -38,17 +32,18 @@ const getNoteParams = () => {
const params = [];
for (const key in config) {
if (config.hasOwnProperty(key)) {
params.push(key + '=' + encodeURIComponent(config[key]));
params.push(`${key}=${encodeURIComponent(config[key])}`);
}
}
return params.join('&');
};
const isLocked = () => {
const meeting = Meetings.findOne({ meetingId: Auth.meetingID });
const user = getCurrentUser();
const meeting = Meetings.findOne({ meetingId: Auth.meetingID }, { fields: { 'lockSettingsProps.disableNote': 1 } });
const user = Users.findOne({ userId: Auth.userID }, { fields: { locked: 1, role: 1 } });
if (meeting.lockSettingsProps && mapUser(user).isLocked) {
const ROLE_MODERATOR = Meteor.settings.public.user.role_moderator;
if (meeting.lockSettingsProps && user.locked && user.role !== ROLE_MODERATOR) {
return meeting.lockSettingsProps.disableNote;
}
return false;
@ -56,19 +51,19 @@ const isLocked = () => {
const getReadOnlyURL = () => {
const readOnlyNoteId = getReadOnlyNoteId();
const url = Auth.authenticateURL(NOTE_CONFIG.url + '/p/' + readOnlyNoteId);
const url = Auth.authenticateURL(`${NOTE_CONFIG.url}/p/${readOnlyNoteId}`);
return url;
};
const getNoteURL = () => {
const noteId = getNoteId();
const params = getNoteParams();
const url = Auth.authenticateURL(NOTE_CONFIG.url + '/p/' + noteId + '?' + params);
const url = Auth.authenticateURL(`${NOTE_CONFIG.url}/p/${noteId}?${params}`);
return url;
};
const getRevs = () => {
const note = Note.findOne({ meetingId: Auth.meetingID });
const note = Note.findOne({ meetingId: Auth.meetingID }, { fields: { revs: 1 } });
return note ? note.revs : 0;
};
@ -77,9 +72,7 @@ const isEnabled = () => {
return NOTE_CONFIG.enabled && note;
};
const isPanelOpened = () => {
return Session.get('openPanel') === 'note';
};
const isPanelOpened = () => Session.get('openPanel') === 'note';
export default {
getNoteURL,

View File

@ -14,7 +14,7 @@ export default withTracker(() => {
const currentPresentation = Presentations.findOne({
current: true,
}) || {};
}, { fields: { podId: 1 } }) || {};
const currentSlide = PresentationAreaService.getCurrentSlide(currentPresentation.podId);

View File

@ -190,7 +190,7 @@ const uploadAndConvertPresentations = (
const setPresentation = (presentationId, podId) => makeCall('setPresentation', presentationId, podId);
const removePresentation = (presentationId, podId) => {
const hasPoll = Poll.find({}).fetch().length;
const hasPoll = Poll.find({}, { fields: {} }).count();
if (hasPoll) makeCall('stopPoll');
makeCall('removePresentation', presentationId, podId);
};

View File

@ -7,10 +7,10 @@ import Users from '/imports/api/users';
import Annotations from '/imports/api/annotations';
import AnnotationsTextService from '/imports/ui/components/whiteboard/annotations/text/service';
import AnnotationsLocal from '/imports/ui/components/whiteboard/service';
import mapUser from '/imports/ui/services/user/mapUser';
const CHAT_CONFIG = Meteor.settings.public.chat;
const ROLE_MODERATOR = Meteor.settings.public.user.role_moderator;
const CHAT_ENABLED = CHAT_CONFIG.enabled;
const PUBLIC_GROUP_CHAT_ID = CHAT_CONFIG.public_group_id;
const PUBLIC_CHAT_TYPE = CHAT_CONFIG.type_public;
@ -90,10 +90,10 @@ export default withTracker(() => {
const User = Users.findOne({ intId: requesterUserId });
if (User) {
const mappedUser = mapUser(User);
Meteor.subscribe('users', credentials, mappedUser.isModerator, subscriptionErrorHandler);
Meteor.subscribe('breakouts', credentials, mappedUser.isModerator, subscriptionErrorHandler);
Meteor.subscribe('meetings', credentials, mappedUser.isModerator, subscriptionErrorHandler);
const userIsModerator = User.role === ROLE_MODERATOR;
Meteor.subscribe('users', credentials, userIsModerator, subscriptionErrorHandler);
Meteor.subscribe('breakouts', credentials, userIsModerator, subscriptionErrorHandler);
Meteor.subscribe('meetings', credentials, userIsModerator, subscriptionErrorHandler);
}
const annotationsHandler = Meteor.subscribe('annotations', credentials, {

View File

@ -6,7 +6,6 @@ import Meetings from '/imports/api/meetings';
import Auth from '/imports/ui/services/auth';
import UnreadMessages from '/imports/ui/services/unread-messages';
import Storage from '/imports/ui/services/storage/session';
import mapUser from '/imports/ui/services/user/mapUser';
import { EMOJI_STATUSES } from '/imports/utils/statuses';
import { makeCall } from '/imports/ui/services/api';
import _ from 'lodash';
@ -189,9 +188,9 @@ const getUsers = () => {
}, userFindSorting)
.fetch();
const currentUser = Users.findOne({ userId: Auth.userID });
const currentUser = Users.findOne({ userId: Auth.userID }, { fields: { role: 1, locked: 1 } });
if (currentUser && currentUser.role === ROLE_VIEWER && currentUser.locked) {
const meeting = Meetings.findOne({ meetingId: Auth.meetingID });
const meeting = Meetings.findOne({ meetingId: Auth.meetingID }, { fields: { 'lockSettingsProps.hideUserList': 1 } });
if (meeting && meeting.lockSettingsProps && meeting.lockSettingsProps.hideUserList) {
const moderatorOrCurrentUser = u => u.role === ROLE_MODERATOR || u.userId === Auth.userID;
users = users.filter(moderatorOrCurrentUser);
@ -201,11 +200,12 @@ const getUsers = () => {
return users.sort(sortUsers);
};
const hasBreakoutRoom = () => Breakouts.find({ parentMeetingId: Auth.meetingID }).count() > 0;
const hasBreakoutRoom = () => Breakouts.find({ parentMeetingId: Auth.meetingID },
{ fields: {} }).count() > 0;
const getActiveChats = (chatID) => {
const privateChat = GroupChat
.find({ users: { $all: [Auth.userID] } })
.find({ users: { $all: [Auth.userID] } }, { fields: { chatId: 1 } })
.fetch()
.map(chat => chat.chatId);
@ -229,11 +229,10 @@ const getActiveChats = (chatID) => {
activeChats = _.uniq(_.compact(activeChats));
activeChats = Users
.find({ userId: { $in: activeChats } })
.map(mapUser)
.find({ userId: { $in: activeChats } }, { fields: { userId: 1 } })
.map((op) => {
const activeChat = op;
activeChat.unreadCounter = UnreadMessages.count(op.id);
activeChat.unreadCounter = UnreadMessages.count(op.userId);
return activeChat;
});
@ -357,13 +356,6 @@ const getAvailableActions = (currentUser, user, isBreakoutRoom) => {
};
};
const getCurrentUser = () => {
const currentUserId = Auth.userID;
const currentUser = Users.findOne({ userId: currentUserId });
return (currentUser) ? mapUser(currentUser) : null;
};
const normalizeEmojiName = emoji => (
emoji in EMOJI_STATUSES ? EMOJI_STATUSES[emoji] : emoji
);
@ -488,7 +480,6 @@ export default {
changeRole,
getUsers,
getActiveChats,
getCurrentUser,
getAvailableActions,
normalizeEmojiName,
isMeetingLocked,

View File

@ -153,7 +153,6 @@ class UserDropdown extends PureComponent {
}
componentDidUpdate() {
const { dropdownVisible } = this.props;
this.checkDropdownDirection();
}

View File

@ -71,13 +71,15 @@ const UserName = (props) => {
}
if (isMeetingLocked(meetingId) && user.isLocked) {
userNameSub.push(<span>
<Icon iconName="lock" />
{intl.formatMessage(messages.locked)}
</span>);
userNameSub.push(
<span>
<Icon iconName="lock" />
{intl.formatMessage(messages.locked)}
</span>,
);
}
if (user.isGuest) {
if (user.isGuest) { // FIXME- isGuest is not defined
userNameSub.push(intl.formatMessage(messages.guest));
}
@ -89,13 +91,17 @@ const UserName = (props) => {
aria-expanded={isActionsOpen}
>
<span className={styles.userNameMain}>
{user.name} <i>{(user.isCurrent) ? `(${intl.formatMessage(messages.you)})` : ''}</i>
{user.name}
{' '}
<i>{(user.isCurrent) ? `(${intl.formatMessage(messages.you)})` : ''}</i>
</span>
{
userNameSub.length ?
<span className={styles.userNameSub}>
{userNameSub.reduce((prev, curr) => [prev, ' | ', curr])}
</span>
userNameSub.length
? (
<span className={styles.userNameSub}>
{userNameSub.reduce((prev, curr) => [prev, ' | ', curr])}
</span>
)
: null
}
</div>

View File

@ -6,8 +6,6 @@ import userListService from '/imports/ui/components/user-list/service';
import logger from '/imports/startup/client/logger';
import { defineMessages, injectIntl, intlShape } from 'react-intl';
import { notify } from '/imports/ui/services/notification';
import mapUser from '/imports/ui/services/user/mapUser';
import Users from '/imports/api/users';
import UserOptions from './component';
const propTypes = {
@ -42,7 +40,6 @@ const UserOptionsContainer = withTracker((props) => {
intl.formatMessage(intlMessages.clearStatusMessage), 'info', 'clear_status',
);
};
const currentUser = Users.findOne({ userId: Auth.userID });
const isMeetingMuteOnStart = () => {
const { voiceProp } = meeting;
@ -88,7 +85,6 @@ const UserOptionsContainer = withTracker((props) => {
users: Service.users(),
userListService,
isMeteorConnected: Meteor.status().connected,
currentUser: currentUser ? mapUser(currentUser) : {},
};
})(UserOptions);

View File

@ -15,12 +15,14 @@ export default withTracker(() => ({
hasStream: true,
role: ROLE_VIEWER,
presenter: false,
}).count(),
currentUserIsModerator: Users.findOne({ userId: Auth.userID }).role === ROLE_MODERATOR,
lockSettings: Meetings.findOne({ meetingId: Auth.meetingID }).lockSettingsProps,
}, { fields: {} }).count(),
currentUserIsModerator: Users.findOne({ userId: Auth.userID },
{ fields: { role: 1 } }).role === ROLE_MODERATOR,
lockSettings: Meetings.findOne({ meetingId: Auth.meetingID },
{ fields: { lockSettingsProps: 1 } }).lockSettingsProps,
webcamOnlyForModerator: Meetings.findOne({
meetingId: Auth.meetingID,
}).usersProp.webcamsOnlyForModerator,
}, { fields: { 'usersProp.webcamsOnlyForModerator': 1 } }).usersProp.webcamsOnlyForModerator,
limitOfViewersInWebcam: Meteor.settings.public.app.viewersInWebcam,
limitOfViewersInWebcamIsEnable: Meteor.settings.public.app.enableLimitOfViewersInWebcam,
toggleWebcamsOnlyForModerator: LockViewersService.toggleWebcamsOnlyForModerator,

View File

@ -1,10 +1,11 @@
import Settings from '/imports/ui/services/settings';
import mapUser from '/imports/ui/services/user/mapUser';
import Auth from '/imports/ui/services/auth';
import Users from '/imports/api/users/';
import VideoService from '../service';
const baseName = Meteor.settings.public.app.cdn + Meteor.settings.public.app.basename;
const PUBLIC_SETTINGS = Meteor.settings.public;
const baseName = PUBLIC_SETTINGS.app.cdn + PUBLIC_SETTINGS.app.basename;
const ROLE_MODERATOR = PUBLIC_SETTINGS.user.role_moderator;
const isSharingVideo = () => {
const userId = Auth.userID;
@ -19,8 +20,8 @@ const isDisabled = () => {
const isConnected = VideoService.isConnected();
const lockCam = VideoService.webcamsLocked();
const user = Users.findOne({ userId: Auth.userID });
const userLocked = mapUser(user).isLocked;
const user = Users.findOne({ userId: Auth.userID }, { fields: { locked: 1, role: 1 } });
const userLocked = user.locked && user.role !== ROLE_MODERATOR;
const isConnecting = (!isSharingVideo && isConnected);

View File

@ -268,7 +268,7 @@ class AudioManager {
// listen to the VoiceUsers changes and update the flag
if (!this.muteHandle) {
const query = VoiceUsers.find({ intId: Auth.userID });
const query = VoiceUsers.find({ intId: Auth.userID }, { fields: { muted: 1, talking: 1 } });
this.muteHandle = query.observeChanges({
changed: (id, fields) => {
if (fields.muted !== undefined && fields.muted !== this.isMuted) {

View File

@ -219,7 +219,10 @@ class Auth {
Meteor.subscribe('current-user', this.credentials);
const selector = { meetingId: this.meetingID, userId: this.userID };
const User = Users.findOne(selector);
const fields = {
intId: 1, ejected: 1, validated: 1, connectionStatus: 1,
};
const User = Users.findOne(selector, { fields });
// Skip in case the user is not in the collection yet or is a dummy user
if (!User || !('intId' in User)) {
logger.info({ logCode: 'auth_service_resend_validateauthtoken' }, 're-send validateAuthToken for delayed authentication');

View File

@ -155,7 +155,8 @@ export const startBandwidthMonitoring = () => {
}
}
const lastEffectiveConnectionType = Users.findOne({ userId: Auth.userID });
const lastEffectiveConnectionType = Users.findOne({ userId: Auth.userID },
{ fields: { effectiveConnectionType: 1 } });
if (lastEffectiveConnectionType
&& lastEffectiveConnectionType.effectiveConnectionType !== effectiveType) {

View File

@ -12,7 +12,10 @@ const PUBLIC_GROUP_CHAT_ID = CHAT_CONFIG.public_group_id;
class UnreadMessagesTracker {
constructor() {
this._tracker = new Tracker.Dependency();
this._unreadChats = { ...Storage.getItem('UNREAD_CHATS'), [PUBLIC_GROUP_CHAT_ID]: (new Date()).getTime() };
this._unreadChats = {
...Storage.getItem('UNREAD_CHATS'),
[PUBLIC_GROUP_CHAT_ID]: (new Date()).getTime(),
};
this.get = this.get.bind(this);
}
@ -42,7 +45,8 @@ class UnreadMessagesTracker {
if (chatID === PUBLIC_GROUP_CHAT_ID) {
filter.chatId = { $eq: chatID };
} else {
const privateChat = GroupChat.findOne({ users: { $all: [chatID, Auth.userID] } });
const privateChat = GroupChat.findOne({ users: { $all: [chatID, Auth.userID] } },
{ fields: { chatId: 1 } });
filter.chatId = { $ne: PUBLIC_GROUP_CHAT_ID };