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/2.0/voice-users';
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,
2017-10-04 03:22:26 +08:00
isVoiceUser: !!voiceUser,
isMuted: voiceUser ? voiceUser.muted : false,
isTalking: voiceUser ? voiceUser.talking : false,
isListenOnly: voiceUser ? voiceUser.listenOnly : false,
2017-08-01 21:10:12 +08:00
isSharingWebcam: 0,
isPhoneUser: user.phone_user,
isOnline: user.connectionStatus === 'online',
2017-10-04 03:22:26 +08:00
isLocked: user.locked,
2017-08-01 21:10:12 +08:00
};
2017-08-01 21:41:24 +08:00
return mappedUser;
2017-08-01 21:10:12 +08:00
};
2017-10-04 03:22:26 +08:00
2017-08-01 21:10:12 +08:00
export default mapUser;