Refactor user
This commit is contained in:
parent
51f7161e45
commit
eea2c0ee8b
@ -15,14 +15,14 @@ export default function addPoll(meetingId, requesterId, poll) {
|
||||
|
||||
const options = {
|
||||
fields: {
|
||||
'user.userid': 1,
|
||||
userId: 1,
|
||||
_id: 0,
|
||||
},
|
||||
};
|
||||
|
||||
const userIds = Users.find(selector, options)
|
||||
.fetch()
|
||||
.map(user => user.user.userid);
|
||||
.map(user => user.userId);
|
||||
|
||||
selector = {
|
||||
meetingId,
|
||||
|
@ -15,8 +15,8 @@ export default function handleEmojiStatus({ body }, meetingId) {
|
||||
|
||||
const modifier = {
|
||||
$set: {
|
||||
'user.set_emoji_time': (new Date()).getTime(),
|
||||
'user.emoji': emoji,
|
||||
emojiTime: (new Date()).getTime(),
|
||||
emoji,
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -3,7 +3,7 @@ import Logger from '/imports/startup/server/logger';
|
||||
import Users from '/imports/api/2.0/users';
|
||||
|
||||
export default function handleListeningOnly({ payload }, meetingId) {
|
||||
const userId = payload.userid;
|
||||
const userId = payload.userId;
|
||||
const listenOnly = payload.listen_only;
|
||||
|
||||
check(userId, String);
|
||||
|
@ -44,7 +44,7 @@ export default function listenOnlyToggle(credentials, isJoining = true) {
|
||||
check(User.user.name, String);
|
||||
|
||||
const payload = {
|
||||
userid: requesterUserId,
|
||||
userId: requesterUserId,
|
||||
meeting_id: meetingId,
|
||||
voice_conf: Meeting.voiceConf,
|
||||
name: User.user.name,
|
||||
|
@ -30,11 +30,11 @@ export default function userLeaving(credentials, userId) {
|
||||
'user-not-found', `Could not find ${userId} in ${meetingId}: cannot complete userLeaving`);
|
||||
}
|
||||
|
||||
if (User.user.connection_status === OFFLINE_CONNECTION_STATUS) {
|
||||
if (User.connectionStatus === OFFLINE_CONNECTION_STATUS) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (User.user.listenOnly) {
|
||||
if (User.listenOnly) {
|
||||
listenOnlyToggle(credentials, false);
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,7 @@
|
||||
import { check } from 'meteor/check';
|
||||
import Logger from '/imports/startup/server/logger';
|
||||
import Users from '/imports/api/2.0/users';
|
||||
|
||||
import requestStunTurn from '../methods/requestStunTurn';
|
||||
import flat from 'flat';
|
||||
|
||||
export default function addUser(meetingId, user) {
|
||||
check(user, Object);
|
||||
@ -37,36 +36,29 @@ export default function addUser(meetingId, user) {
|
||||
userRoles.push(user.presenter ? 'presenter' : undefined);
|
||||
userRoles.push(user.role === 'MODERATOR' ? 'moderator' : undefined);
|
||||
|
||||
/**
|
||||
* {
|
||||
"intId": "w_opaqxrriwvga",
|
||||
"extId": "w_opaqxrriwvga",
|
||||
"name": "html5",
|
||||
"role": "VIEWER",
|
||||
"guest": false,
|
||||
"authed": false,
|
||||
"waitingForAcceptance": false,
|
||||
"emoji": "none",
|
||||
"presenter": false,
|
||||
"locked": false,
|
||||
"avatar": "http://localhost/client/avatar.png"
|
||||
}
|
||||
*/
|
||||
const modifier = {
|
||||
$set: {
|
||||
meetingId,
|
||||
userId,
|
||||
'user.connection_status': 'online',
|
||||
'user.userid': userId,
|
||||
'user.extId': user.extId,
|
||||
'user.role': user.role,
|
||||
'user.roles': userRoles,
|
||||
'user.name': user.name,
|
||||
'user._sort_name': user.name.trim().toLowerCase(),
|
||||
'user.avatarURL': user.avatar,
|
||||
'user.set_emoji_time': user.set_emoji_time || (new Date()).getTime(),
|
||||
'user.joiningTime': (new Date()).getTime(),
|
||||
'user.emoji': user.emoji,
|
||||
'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,
|
||||
},
|
||||
$set: Object.assign(
|
||||
{ meetingId },
|
||||
{ connectionStatus: 'online' },
|
||||
{ roles: userRoles },
|
||||
{ sortName: user.name.trim().toLowerCase() },
|
||||
flat(user),
|
||||
),
|
||||
};
|
||||
|
||||
const cb = (err, numChanged) => {
|
||||
|
@ -15,16 +15,12 @@ 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,
|
||||
'user.emoji': 'none',
|
||||
'user.presenter': false,
|
||||
'user.role': 'VIEWER',
|
||||
connectionStatus: 'offline',
|
||||
listenOnly: false,
|
||||
validated: false,
|
||||
emoji: 'none',
|
||||
presenter: false,
|
||||
role: 'VIEWER',
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -22,7 +22,7 @@ export default function setConnectionStatus(meetingId, userId, status = 'online'
|
||||
|
||||
const modifier = {
|
||||
$set: {
|
||||
'user.connection_status': status,
|
||||
connectionStatus: status,
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -11,7 +11,7 @@ const getEmojiData = () => {
|
||||
const userEmojiStatus = Users.findOne({
|
||||
meetingId: Auth.meetingID,
|
||||
userId: Auth.userID,
|
||||
}).user.emoji;
|
||||
}).emoji;
|
||||
|
||||
return {
|
||||
userEmojiStatus,
|
||||
|
@ -16,10 +16,10 @@ class MuteAudioContainer extends React.Component {
|
||||
|
||||
export default createContainer((params) => {
|
||||
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;
|
||||
// FIXME const user = Users.findOne({ userId }).user;
|
||||
const isMuted = true; // FIXME user.voiceUser.muted;
|
||||
const isInAudio = false; // FIXME user.voiceUser.joined;
|
||||
const isTalking = false; // FIXME user.voiceUser.talking;
|
||||
|
||||
let callback = () => { };
|
||||
|
||||
|
@ -4,7 +4,7 @@ import Users from '/imports/api/2.0/users';
|
||||
|
||||
const isUserPresenter = () => Users.findOne({
|
||||
userId: Auth.userID,
|
||||
}).user.presenter;
|
||||
}).presenter;
|
||||
|
||||
export default {
|
||||
isUserPresenter,
|
||||
|
@ -14,10 +14,10 @@ class JoinAudioOptionsContainer extends React.Component {
|
||||
}
|
||||
|
||||
export default createContainer((params) => {
|
||||
const user = Users.findOne({ userId: Auth.userID }).user;
|
||||
const user = Users.findOne({ userId: Auth.userID });
|
||||
|
||||
return {
|
||||
isInAudio: user.voiceUser.joined,
|
||||
isInAudio: false, // FIXME user.voiceUser.joined,
|
||||
isInListenOnly: user.listenOnly,
|
||||
handleJoinAudio: params.handleJoinAudio,
|
||||
handleCloseAudio: params.handleCloseAudio,
|
||||
|
@ -7,7 +7,7 @@ let audioManager;
|
||||
const init = () => {
|
||||
const userId = Auth.userID;
|
||||
const User = Users.findOne({ userId });
|
||||
const username = User.user.name;
|
||||
const username = User.name;
|
||||
|
||||
const turns = [];
|
||||
const stuns = [];
|
||||
|
@ -25,20 +25,20 @@ 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,
|
||||
id: user.userId,
|
||||
name: user.name,
|
||||
emoji: {
|
||||
status: user.emoji,
|
||||
changedAt: user.set_emoji_time,
|
||||
changedAt: user.emojiTime,
|
||||
},
|
||||
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,
|
||||
isCurrent: user.userId === Auth.userID,
|
||||
isVoiceUser: false, // FIXME user.voiceUser.joined,
|
||||
isOnline: user.connectionStatus === 'online',
|
||||
isMuted: false, // FIXME user.voiceUser.muted,
|
||||
isListenOnly: user.listenOnly,
|
||||
isSharingWebcam: user.webcam_stream.length,
|
||||
isSharingWebcam: 0, // FIXME user.webcam_stream.length,
|
||||
isLocked: user.locked,
|
||||
});
|
||||
|
||||
@ -49,7 +49,7 @@ const getUser = (userID) => {
|
||||
return null;
|
||||
}
|
||||
|
||||
return mapUser(user.user);
|
||||
return mapUser(user);
|
||||
};
|
||||
|
||||
const mapMessage = (messagePayload) => {
|
||||
|
@ -17,8 +17,8 @@ const getSlideData = (params) => {
|
||||
});
|
||||
|
||||
let userIsPresenter;
|
||||
if (currentUser && currentUser.user) {
|
||||
userIsPresenter = currentUser.user.presenter;
|
||||
if (currentUser) {
|
||||
userIsPresenter = currentUser.presenter;
|
||||
}
|
||||
|
||||
// Get total number of slides in this presentation
|
||||
|
@ -26,8 +26,8 @@ const getCurrentCursor = () => Cursor.findOne({});
|
||||
const isPresenter = () => {
|
||||
const currentUser = Users.findOne({ userId: Auth.userID });
|
||||
|
||||
if (currentUser && currentUser.user) {
|
||||
return currentUser.user.presenter;
|
||||
if (currentUser) {
|
||||
return currentUser.presenter;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -17,7 +17,7 @@ const getClosedCaptionLocales = () => {
|
||||
const getUserRoles = () => {
|
||||
const user = Users.findOne({
|
||||
userId: Auth.userID,
|
||||
}).user;
|
||||
});
|
||||
|
||||
return user.role;
|
||||
};
|
||||
|
@ -236,6 +236,8 @@ class UserList extends Component {
|
||||
},
|
||||
};
|
||||
|
||||
console.log("Users",users);
|
||||
|
||||
return (
|
||||
<div className={styles.participants}>
|
||||
{
|
||||
|
@ -18,22 +18,22 @@ 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,
|
||||
id: user.userId,
|
||||
name: user.name,
|
||||
emoji: {
|
||||
status: user.emoji,
|
||||
changedAt: user.set_emoji_time,
|
||||
changedAt: user.emojiTime,
|
||||
},
|
||||
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,
|
||||
isCurrent: user.userId === Auth.userID,
|
||||
isVoiceUser: false, // FIXME user.voiceUser.joined,
|
||||
isMuted: false, // FIXME user.voiceUser.muted,
|
||||
isTalking: false, // FIXME user.voiceUser.talking,
|
||||
isListenOnly: user.listenOnly,
|
||||
isSharingWebcam: user.webcam_stream.length,
|
||||
isPhoneUser: user.phone_user,
|
||||
isOnline: user.connection_status === 'online',
|
||||
isSharingWebcam: 0, // FIXME user.webcam_stream.length,
|
||||
isPhoneUser: user.phoneUser,
|
||||
isOnline: user.connectionStatus === 'online',
|
||||
isLocked: user.locked,
|
||||
});
|
||||
|
||||
@ -156,20 +156,19 @@ const sortChats = (a, b) => {
|
||||
};
|
||||
|
||||
const userFindSorting = {
|
||||
'user.set_emoji_time': 1,
|
||||
'user.role': 1,
|
||||
'user.phone_user': 1,
|
||||
'user._sort_name': 1,
|
||||
'user.userid': 1,
|
||||
emojiTime: 1,
|
||||
role: 1,
|
||||
phoneUser: 1,
|
||||
sortName: 1,
|
||||
userId: 1,
|
||||
};
|
||||
|
||||
const getUsers = () => {
|
||||
const users = Users
|
||||
.find({ 'user.connection_status': 'online' }, userFindSorting)
|
||||
.find({ connectionStatus: 'online' }, userFindSorting)
|
||||
.fetch();
|
||||
|
||||
return users
|
||||
.map(u => u.user)
|
||||
.map(mapUser)
|
||||
.sort(sortUsers);
|
||||
};
|
||||
@ -187,8 +186,7 @@ const getOpenChats = (chatID) => {
|
||||
openChats = _.uniq(openChats);
|
||||
|
||||
openChats = Users
|
||||
.find({ 'user.userid': { $in: openChats } })
|
||||
.map(u => u.user)
|
||||
.find({ userId: { $in: openChats } })
|
||||
.map(mapUser)
|
||||
.map((op) => {
|
||||
const openChat = op;
|
||||
@ -230,9 +228,9 @@ const getOpenChats = (chatID) => {
|
||||
|
||||
const getCurrentUser = () => {
|
||||
const currentUserId = Auth.userID;
|
||||
const currentUser = Users.findOne({ 'user.userid': currentUserId });
|
||||
const currentUser = Users.findOne({ userId: currentUserId });
|
||||
|
||||
return (currentUser) ? mapUser(currentUser.user) : null;
|
||||
return (currentUser) ? mapUser(currentUser) : null;
|
||||
};
|
||||
|
||||
export default {
|
||||
|
Loading…
Reference in New Issue
Block a user