2017-08-01 03:36:41 +08:00
|
|
|
import { check } from 'meteor/check';
|
2017-12-08 04:50:50 +08:00
|
|
|
import Users from '/imports/api/users';
|
2018-07-17 01:03:01 +08:00
|
|
|
import addUser from '/imports/api/users/server/modifiers/addUser';
|
2017-08-01 03:36:41 +08:00
|
|
|
import addVoiceUser from '../modifiers/addVoiceUser';
|
|
|
|
|
|
|
|
export default function handleJoinVoiceUser({ body }, meetingId) {
|
|
|
|
const voiceUser = body;
|
2017-08-02 21:11:53 +08:00
|
|
|
voiceUser.joined = true;
|
2017-08-01 03:36:41 +08:00
|
|
|
|
|
|
|
check(meetingId, String);
|
2017-12-08 04:50:50 +08:00
|
|
|
check(voiceUser, {
|
|
|
|
voiceConf: String,
|
|
|
|
intId: String,
|
|
|
|
voiceUserId: String,
|
|
|
|
callerName: String,
|
|
|
|
callerNum: String,
|
|
|
|
muted: Boolean,
|
|
|
|
talking: Boolean,
|
|
|
|
callingWith: String,
|
|
|
|
listenOnly: Boolean,
|
|
|
|
joined: Boolean,
|
|
|
|
});
|
|
|
|
|
|
|
|
const {
|
|
|
|
intId,
|
|
|
|
callerName,
|
|
|
|
} = voiceUser;
|
|
|
|
|
2018-07-17 01:03:01 +08:00
|
|
|
const User = Users.findOne({
|
|
|
|
meetingId,
|
|
|
|
intId,
|
|
|
|
connectionStatus: 'online',
|
|
|
|
});
|
2017-12-08 04:50:50 +08:00
|
|
|
|
2018-07-17 01:03:01 +08:00
|
|
|
if (!User) {
|
|
|
|
/* voice-only user - called into the conference */
|
2017-12-08 04:50:50 +08:00
|
|
|
|
|
|
|
const USER_CONFIG = Meteor.settings.public.user;
|
|
|
|
const ROLE_VIEWER = USER_CONFIG.role_viewer;
|
|
|
|
|
2018-07-17 01:03:01 +08:00
|
|
|
const voiceOnlyUser = { // web (Users) representation of dial-in user
|
|
|
|
intId,
|
|
|
|
extId: intId, // TODO
|
|
|
|
name: callerName,
|
|
|
|
role: ROLE_VIEWER.toLowerCase(),
|
|
|
|
guest: false,
|
|
|
|
authed: true,
|
|
|
|
waitingForAcceptance: false,
|
2018-08-16 00:45:00 +08:00
|
|
|
guestStatus: 'ALLOW',
|
2018-07-17 01:03:01 +08:00
|
|
|
emoji: 'none',
|
|
|
|
presenter: false,
|
|
|
|
locked: false, // TODO
|
2018-08-16 01:31:07 +08:00
|
|
|
avatar: '',
|
2018-07-17 01:03:01 +08:00
|
|
|
clientType: 'dial-in-user',
|
2017-12-08 04:50:50 +08:00
|
|
|
};
|
|
|
|
|
2018-07-17 01:03:01 +08:00
|
|
|
addUser(meetingId, voiceOnlyUser);
|
2017-12-08 04:50:50 +08:00
|
|
|
}
|
2017-08-01 03:36:41 +08:00
|
|
|
|
|
|
|
return addVoiceUser(meetingId, voiceUser);
|
|
|
|
}
|