Move from users to voice-users

This commit is contained in:
Klaus 2017-08-01 10:10:12 -03:00
parent 1ff3df770a
commit 9d42ca9bd7
26 changed files with 115 additions and 318 deletions

View File

@ -1,6 +1,7 @@
import { check } from 'meteor/check';
import Logger from '/imports/startup/server/logger';
import Users from '/imports/api/2.0/users';
import addVoiceUser from '/imports/api/2.0/voice-users/server/modifiers/addVoiceUser';
export default function addUser(meetingId, user) {
check(user, Object);
@ -58,20 +59,21 @@ export default function addUser(meetingId, user) {
'user.presenter': user.presenter,
'user.locked': user.locked,
'user.listenOnly': user.listenOnly,
// default values for voiceUser and webcam
'user.webcam_stream': [],
'user.voiceUser.web_userid': false,
'user.voiceUser.callernum': false,
'user.voiceUser.userid': false,
'user.voiceUser.talking': false,
'user.voiceUser.joined': false,
'user.voiceUser.callername': false,
'user.voiceUser.locked': false,
'user.voiceUser.muted': false,
},
};
addVoiceUser(meetingId, {
voiceUserId: '',
intId: userId,
callerName: user.name,
callerNum: '',
muted: false,
talking: false,
callingWith: '',
listenOnly: false,
voiceConf: '',
});
const cb = (err, numChanged) => {
if (err) {
return Logger.error(`Adding user to collection: ${err}`);

View File

@ -16,9 +16,6 @@ export default function removeUser(meetingId, userId) {
const modifier = {
$set: {
'user.connection_status': 'offline',
'user.voiceUser.talking': false,
'user.voiceUser.joined': false,
'user.voiceUser.muted': false,
'user.time_of_joining': 0,
'user.listenOnly': false,
'user.validated': false,
@ -28,14 +25,12 @@ export default function removeUser(meetingId, userId) {
},
};
const cb = (err, numChanged) => {
const cb = (err) => {
if (err) {
return Logger.error(`Removing user from collection: ${err}`);
}
if (numChanged) {
return Logger.info(`Removed ${CLIENT_TYPE_HTML} user id=${userId} meeting=${meetingId}`);
}
return Logger.info(`Removed ${CLIENT_TYPE_HTML} user id=${userId} meeting=${meetingId}`);
};
return Users.update(selector, modifier, cb);

View File

@ -1,34 +0,0 @@
import { check } from 'meteor/check';
import Logger from '/imports/startup/server/logger';
import Users from '/imports/api/2.0/users';
export default function updateVoiceUser(meetingId, voiceUser) {
check(meetingId, String);
check(voiceUser, Object);
const selector = {
meetingId,
user: voiceUser.intId,
};
const modifier = {
$set: {
'user.voiceUser.talking': voiceUser.talking,
'user.voiceUser.joined': voiceUser.joined,
'user.voiceUser.locked': voiceUser.locked,
'user.voiceUser.muted': voiceUser.muted,
},
};
const cb = (err, numChanged) => {
if (err) {
return Logger.error(`Updating voice user=${voiceUser.intId}: ${err}`);
}
if (numChanged) {
return Logger.verbose(`Updated voice user=${voiceUser.intId} meeting=${meetingId}`);
}
};
return Users.update(selector, modifier, cb);
}

View File

@ -1 +0,0 @@
export default new Mongo.Collection('voiceUser');

View File

@ -1,10 +0,0 @@
import RedisPubSub from '/imports/startup/server/redis2x';
import handleJoinVoiceUser from './handlers/joinVoiceUser';
import handleLeftVoiceUser from './handlers/leftVoiceUser';
import handleTalkingVoiceUser from './handlers/talkingVoiceUser';
import handleMutedVoiceUser from './handlers/mutedVoiceUser';
RedisPubSub.on('UserLeftVoiceConfToClientEvtMsg', handleLeftVoiceUser);
RedisPubSub.on('UserJoinedVoiceConfToClientEvtMsg', handleJoinVoiceUser);
RedisPubSub.on('UserTalkingVoiceEvtMsg', handleTalkingVoiceUser);
RedisPubSub.on('UserMutedVoiceEvtMsg', handleMutedVoiceUser);

View File

@ -1,11 +0,0 @@
import { check } from 'meteor/check';
import addVoiceUser from '../modifiers/addVoiceUser';
export default function handleJoinVoiceUser({ body }, meetingId) {
const voiceUser = body;
check(meetingId, String);
return addVoiceUser(meetingId, voiceUser);
}

View File

@ -1,11 +0,0 @@
import { check } from 'meteor/check';
import removeVoiceUser from '../modifiers/removeVoiceUser';
export default function handleVoiceUpdate({ body }, meetingId) {
const voiceUser = body;
check(meetingId, String);
return removeVoiceUser(meetingId, voiceUser);
}

View File

@ -1,11 +0,0 @@
import { check } from 'meteor/check';
import updateVoiceUser from '../modifiers/updateVoiceUser';
export default function handleVoiceUpdate({ body }, meetingId) {
const voiceUser = body;
check(meetingId, String);
return updateVoiceUser(meetingId, voiceUser);
}

View File

@ -1,11 +0,0 @@
import { check } from 'meteor/check';
import updateVoiceUser from '../modifiers/updateVoiceUser';
export default function handleVoiceUpdate({ body }, meetingId) {
const voiceUser = body;
check(meetingId, String);
return updateVoiceUser(meetingId, voiceUser);
}

View File

@ -1,2 +0,0 @@
import './eventHandlers';
import './publishers';

View File

@ -1,40 +0,0 @@
import { check } from 'meteor/check';
import Logger from '/imports/startup/server/logger';
import VoiceUser from '/imports/api/2.0/voice-user';
import flat from 'flat';
export default function addVoiceUser(meetingId, voiceUser) {
check(meetingId, String);
check(voiceUser, {
voiceConf: String,
voiceUserId: String,
intId: String,
callerIdName: String,
callerIdNum: String,
muted: Boolean,
talking: Boolean,
callingWith: String,
});
const selector = {
meetingId,
intId: voiceUser.intId,
};
const modifier = {
$set: Object.assign(
{ meetingId },
flat(voiceUser),
),
};
const cb = (err) => {
if (err) {
return Logger.error(`Add voice user=${voiceUser.intId}: ${err}`);
}
return Logger.verbose(`Add voice user=${voiceUser.intId} meeting=${meetingId}`);
};
return VoiceUser.update(selector, modifier, cb);
}

View File

@ -1,15 +0,0 @@
import { check } from 'meteor/check';
import Logger from '/imports/startup/server/logger';
import VoiceUser from '/imports/api/2.0/voice-user';
export default function removeVoiceUser(meetingId, voiceUser) {
check(meetingId, String);
check(voiceUser, {
voiceConf: String,
voiceUserId: String,
});
const { voiceConf, voiceUserId } = voiceUser;
return VoiceUser.remove({ meetingId, voiceConf, voiceUserId }, Logger.info(`Remove VoiceUser voiceUserId=${voiceUserId} meetingId=${meetingId}`));
}

View File

@ -1,36 +0,0 @@
import { Match, check } from 'meteor/check';
import Logger from '/imports/startup/server/logger';
import VoiceUser from '/imports/api/2.0/voice-user';
import flat from 'flat';
export default function removeVoiceUser(meetingId, voiceUser) {
check(meetingId, String);
check(voiceUser, {
intId: String,
voiceUserId: String,
talking: Match.Maybe(Boolean),
muted: Match.Maybe(Boolean),
});
const selector = {
meetingId,
intId: voiceUser.intId,
};
const modifier = {
$set: Object.assign(
{ meetingId },
flat(voiceUser),
),
};
const cb = (err) => {
if (err) {
return Logger.error(`Add voice user=${voiceUser.intId}: ${err}`);
}
return Logger.verbose(`Add voice user=${voiceUser.intId} meeting=${meetingId}`);
};
return VoiceUser.update(selector, modifier, cb);
}

View File

@ -1,23 +0,0 @@
import VoiceUser from '/imports/api/2.0/voice-user';
import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import Logger from '/imports/startup/server/logger';
import mapToAcl from '/imports/startup/mapToAcl';
function voiceUser(credentials) {
const { meetingId, requesterUserId } = credentials;
check(meetingId, String);
check(requesterUserId, String);
Logger.info(`Publishing Voice User for ${meetingId} ${requesterUserId}`);
return VoiceUser.find({ meetingId });
}
function publish(...args) {
const boundVoiceUser = voiceUser.bind(this);
return mapToAcl('subscriptions.voiceUser', boundVoiceUser)(args);
}
Meteor.publish('voiceUser', publish);

View File

@ -1,24 +1,27 @@
import { check } from 'meteor/check';
import Logger from '/imports/startup/server/logger';
import VoiceUser from '/imports/api/2.0/voice-users';
import VoiceUsers from '/imports/api/2.0/voice-users';
import flat from 'flat';
export default function addVoiceUser(meetingId, voiceUser) {
check(meetingId, String);
check(voiceUser, {
voiceConf: String,
voiceUserId: String,
intId: String,
callerIdName: String,
callerIdNum: String,
callerName: String,
callerNum: String,
muted: Boolean,
talking: Boolean,
callingWith: String,
listenOnly: Boolean,
voiceConf: String,
});
const { intId } = voiceUser;
const selector = {
meetingId,
intId: voiceUser.intId,
intId,
};
const modifier = {
@ -30,11 +33,11 @@ export default function addVoiceUser(meetingId, voiceUser) {
const cb = (err) => {
if (err) {
return Logger.error(`Add voice user=${voiceUser.intId}: ${err}`);
return Logger.error(`Add voice user=${intId}: ${err}`);
}
return Logger.verbose(`Add voice user=${voiceUser.intId} meeting=${meetingId}`);
return Logger.verbose(`Add voice user=${intId} meeting=${meetingId}`);
};
return VoiceUser.update(selector, modifier, cb);
return VoiceUsers.upsert(selector, modifier, cb);
}

View File

@ -1,15 +1,35 @@
import { check } from 'meteor/check';
import Logger from '/imports/startup/server/logger';
import VoiceUser from '/imports/api/2.0/voice-users';
import VoiceUsers from '/imports/api/2.0/voice-users';
export default function removeVoiceUser(meetingId, voiceUser) {
check(meetingId, String);
check(voiceUser, {
voiceConf: String,
voiceUserId: String,
intId: String,
});
const { voiceConf, voiceUserId } = voiceUser;
const { intId } = voiceUser;
return VoiceUser.remove({ meetingId, voiceConf, voiceUserId }, Logger.info(`Remove VoiceUser voiceUserId=${voiceUserId} meetingId=${meetingId}`));
const selector = {
meetingId,
intId,
};
const modifier = {
muted: false,
talking: false,
listenOnly: false,
};
const cb = (err) => {
if (err) {
return Logger.error(`Add voice user=${intId}: ${err}`);
}
return Logger.verbose(`Add voice user=${intId} meeting=${meetingId}`);
};
return VoiceUsers.update(selector, modifier, cb);
}

View File

@ -1,6 +1,6 @@
import { Match, check } from 'meteor/check';
import Logger from '/imports/startup/server/logger';
import VoiceUser from '/imports/api/2.0/voice-users';
import VoiceUsers from '/imports/api/2.0/voice-users';
import flat from 'flat';
export default function removeVoiceUser(meetingId, voiceUser) {
@ -10,6 +10,7 @@ export default function removeVoiceUser(meetingId, voiceUser) {
voiceUserId: String,
talking: Match.Maybe(Boolean),
muted: Match.Maybe(Boolean),
voiceConf: String,
});
const selector = {
@ -32,5 +33,5 @@ export default function removeVoiceUser(meetingId, voiceUser) {
return Logger.verbose(`Add voice user=${voiceUser.intId} meeting=${meetingId}`);
};
return VoiceUser.update(selector, modifier, cb);
return VoiceUsers.update(selector, modifier, cb);
}

View File

@ -1,4 +1,4 @@
import VoiceUser from '/imports/api/2.0/voice-users';
import VoiceUsers from '/imports/api/2.0/voice-users';
import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import Logger from '/imports/startup/server/logger';
@ -12,7 +12,7 @@ function voiceUser(credentials) {
Logger.info(`Publishing Voice User for ${meetingId} ${requesterUserId}`);
return VoiceUser.find({ meetingId });
return VoiceUsers.find({ meetingId });
}
function publish(...args) {

View File

@ -6,8 +6,8 @@ import AppContainer from '/imports/ui/components/app/container';
import ErrorScreen from '/imports/ui/components/error-screen/component';
import LoadingScreen from '/imports/ui/components/loading-screen/component';
import Settings from '/imports/ui/services/settings';
import IntlStartup from './intl';
import { initBBB } from '/imports/api/2.0/bbb';
import IntlStartup from './intl';
const BROWSER_LANGUAGE = window.navigator.userLanguage || window.navigator.language;
@ -89,7 +89,7 @@ Base.defaultProps = defaultProps;
const SUBSCRIPTIONS_NAME = [
'users2x', 'users', 'chat', 'chat2x', 'cursor', 'cursor2x', 'screenshare', 'meetings', 'meetings2x',
'polls', 'polls2x', 'presentations', 'presentations2x', 'shapes', 'shapes2x', 'slides', 'slides2x', 'captions',
'captions2x', 'breakouts', 'breakouts2x', 'voiceUser',
'captions2x', 'breakouts', 'breakouts2x', 'voiceUsers',
];
const BaseContainer = createContainer(({ params }) => {

View File

@ -1,41 +1,33 @@
import React from 'react';
import { createContainer } from 'meteor/react-meteor-data';
import { makeCall } from '/imports/ui/services/api';
import Button from '/imports/ui/components/button/component';
import Users from '/imports/api/2.0/users';
import VoiceUsers from '/imports/api/2.0/voice-users';
import Auth from '/imports/ui/services/auth/index';
import MuteAudio from './component';
class MuteAudioContainer extends React.Component {
render() {
return (
<MuteAudio {...this.props} />
);
}
}
const MuteAudioContainer = props => (<MuteAudio {...props} />);
export default createContainer((params) => {
export default createContainer(() => {
const userId = Auth.userID;
const user = Users.findOne({ userId }).user;
const isMuted = user.voiceUser.muted;
const isInAudio = user.voiceUser.joined;
const isTalking = user.voiceUser.talking;
const voiceUser = VoiceUsers.findOne({ intId: userId });
const { muted, joined, talking } = voiceUser;
let callback = () => { };
if (isInAudio && !isMuted) {
if (joined && !muted) {
callback = () => makeCall('muteUser', userId);
}
if (isInAudio && isMuted) {
if (joined && muted) {
callback = () => makeCall('unmuteUser', userId);
}
const data = {
isInAudio,
isMuted,
joined,
muted,
callback,
isTalking,
talking,
};
return data;
}, MuteAudioContainer);

View File

@ -1,24 +1,20 @@
import React from 'react';
import { createContainer } from 'meteor/react-meteor-data';
import Users from '/imports/api/2.0/users';
import VoiceUsers from '/imports/api/2.0/voice-users';
import Auth from '/imports/ui/services/auth/index';
import JoinAudioOptions from './component';
class JoinAudioOptionsContainer extends React.Component {
render() {
return (
<JoinAudioOptions {...this.props} />
);
}
}
const JoinAudioOptionsContainer = props => (<JoinAudioOptions {...props} />);
export default createContainer((params) => {
const user = Users.findOne({ userId: Auth.userID }).user;
const userId = Auth.userID;
const voiceUser = VoiceUsers.findOne({ intId: userId });
const { joined, listenOnly } = voiceUser;
return {
isInAudio: user.voiceUser.joined,
isInListenOnly: user.listenOnly,
joined,
listenOnly,
handleJoinAudio: params.handleJoinAudio,
handleCloseAudio: params.handleCloseAudio,
};

View File

@ -4,6 +4,7 @@ import Users from '/imports/api/2.0/users';
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 { makeCall } from '/imports/ui/services/api';
import _ from 'lodash';
@ -22,26 +23,6 @@ const ScrollCollection = new Mongo.Collection(null);
// session for closed chat list
const CLOSED_CHAT_LIST_KEY = 'closedChatList';
/* TODO: Same map is done in the user-list/service we should share this someway */
const mapUser = user => ({
id: user.userid,
name: user.name,
emoji: {
status: user.emoji,
changedAt: user.set_emoji_time,
},
isPresenter: user.presenter,
isModerator: user.role === 'MODERATOR',
isCurrent: user.userid === Auth.userID,
isVoiceUser: user.voiceUser.joined,
isOnline: user.connection_status === 'online',
isMuted: user.voiceUser.muted,
isListenOnly: user.listenOnly,
isSharingWebcam: user.webcam_stream.length,
isLocked: user.locked,
});
const getUser = (userID) => {
const user = Users.findOne({ userId: userID });
@ -137,7 +118,7 @@ const isChatLocked = (receiverID) => {
/* meeting.roomLockSettings || {
disablePublicChat: false,
disablePrivateChat: false,
};*/
}; */
if (!currentUser.isLocked || currentUser.isPresenter) {
return false;

View File

@ -3,40 +3,17 @@ import Chat from '/imports/api/2.0/chat';
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 _ from 'lodash';
const CHAT_CONFIG = Meteor.settings.public.chat;
const USER_CONFIG = Meteor.settings.public.user;
const ROLE_MODERATOR = USER_CONFIG.role_moderator;
const PRIVATE_CHAT_TYPE = CHAT_CONFIG.type_private;
const PUBLIC_CHAT_USERID = CHAT_CONFIG.public_userid;
// session for closed chat list
const CLOSED_CHAT_LIST_KEY = 'closedChatList';
/* TODO: Same map is done in the chat/service we should share this someway */
const mapUser = user => ({
id: user.userid,
name: user.name,
emoji: {
status: user.emoji,
changedAt: user.set_emoji_time,
},
isPresenter: user.presenter,
isModerator: user.role === ROLE_MODERATOR,
isCurrent: user.userid === Auth.userID,
isVoiceUser: user.voiceUser.joined,
isMuted: user.voiceUser.muted,
isTalking: user.voiceUser.talking,
isListenOnly: user.listenOnly,
isSharingWebcam: user.webcam_stream.length,
isPhoneUser: user.phone_user,
isOnline: user.connection_status === 'online',
isLocked: user.locked,
});
const mapOpenChats = (chat) => {
const currentUserId = Auth.userID;
return chat.message.fromUserId !== currentUserId

View File

@ -0,0 +1,35 @@
import Auth from '/imports/ui/services/auth';
import VoiceUsers from '/imports/api/2.0/voice-users';
const USER_CONFIG = Meteor.settings.public.user;
const ROLE_MODERATOR = USER_CONFIG.role_moderator;
const mapUser = (user) => {
const userId = Auth.userID;
const voiceUser = VoiceUsers.findOne({ intId: userId });
const { muted, joined, talking, listenOnly } = voiceUser;
const mapedUser = {
id: user.userid,
name: user.name,
emoji: {
status: user.emoji,
changedAt: user.set_emoji_time,
},
isPresenter: user.presenter,
isModerator: user.role === ROLE_MODERATOR,
isCurrent: user.userid === userId,
isVoiceUser: joined,
isMuted: muted,
isTalking: talking,
isListenOnly: listenOnly,
isSharingWebcam: 0,
isPhoneUser: user.phone_user,
isOnline: user.connection_status === 'online',
isLocked: user.locked,
};
return mapedUser;
};
export default mapUser;

View File

@ -12,7 +12,7 @@ acl:
- 'slides'
- 'captions'
- 'breakouts'
- 'voiceUser'
- 'voiceUsers'
methods:
- 'listenOnlyToggle'
- 'userLogout'

View File

@ -23,7 +23,7 @@ import '/imports/api/2.0/slides/server';
import '/imports/api/2.0/breakouts/server';
import '/imports/api/2.0/chat/server';
import '/imports/api/2.0/screenshare/server';
import '/imports/api/2.0/voice-user/server';
import '/imports/api/2.0/voice-users/server';
// Commons
import '/imports/api/log-client/server';