bigbluebutton-Github/bigbluebutton-html5/imports/ui/services/user/mapUser.js

40 lines
1.1 KiB
JavaScript
Raw Normal View History

2017-08-01 21:10:12 +08:00
import Auth from '/imports/ui/services/auth';
import VoiceUsers from '/imports/api/voice-users';
2017-08-01 21:10:12 +08:00
const USER_CONFIG = Meteor.settings.public.user;
const ROLE_MODERATOR = USER_CONFIG.role_moderator;
2017-10-04 03:22:26 +08:00
const getVoiceUser = userId => VoiceUsers.findOne({ intId: userId });
2017-08-01 21:10:12 +08:00
const mapUser = (user) => {
const userId = Auth.userID;
2017-10-04 03:22:26 +08:00
const voiceUser = getVoiceUser(user.userId);
2017-08-01 21:10:12 +08:00
2017-08-01 21:41:24 +08:00
const mappedUser = {
id: user.userId,
2017-08-01 21:10:12 +08:00
name: user.name,
color: user.color,
avatar: user.avatar,
2017-08-01 21:10:12 +08:00
emoji: {
status: user.emoji,
changedAt: user.emojiTime,
2017-08-01 21:10:12 +08:00
},
isPresenter: user.presenter,
isModerator: user.role === ROLE_MODERATOR,
isCurrent: user.userId === userId,
isVoiceUser: voiceUser ? voiceUser.joined : false,
2017-10-04 03:22:26 +08:00
isMuted: voiceUser ? voiceUser.muted : false,
isTalking: voiceUser ? voiceUser.talking : false,
isListenOnly: voiceUser ? voiceUser.listenOnly : false,
isSharingWebcam: user.has_stream,
2017-08-01 21:10:12 +08:00
isPhoneUser: user.phone_user,
isOnline: user.connectionStatus === 'online',
2017-08-01 21:10:12 +08:00
};
2018-01-29 19:52:07 +08:00
mappedUser.isLocked = user.locked && !(mappedUser.isPresenter || mappedUser.isModerator);
2017-08-01 21:41:24 +08:00
return mappedUser;
2017-08-01 21:10:12 +08:00
};
export default mapUser;