2017-08-01 03:36:41 +08:00
|
|
|
import { check } from 'meteor/check';
|
|
|
|
|
2017-12-08 04:50:50 +08:00
|
|
|
import removeVoiceUser from '/imports/api/voice-users/server/modifiers/removeVoiceUser';
|
|
|
|
import removeUser from '/imports/api/users/server/modifiers/removeUser';
|
2018-07-17 01:03:01 +08:00
|
|
|
import Users from '/imports/api/users';
|
2017-08-01 03:36:41 +08:00
|
|
|
|
|
|
|
export default function handleVoiceUpdate({ body }, meetingId) {
|
|
|
|
const voiceUser = body;
|
|
|
|
|
|
|
|
check(meetingId, String);
|
2017-12-08 04:50:50 +08:00
|
|
|
check(voiceUser, {
|
|
|
|
voiceConf: String,
|
|
|
|
intId: String,
|
|
|
|
voiceUserId: String,
|
|
|
|
});
|
2017-08-01 03:36:41 +08:00
|
|
|
|
2018-07-17 01:03:01 +08:00
|
|
|
const {
|
|
|
|
intId,
|
|
|
|
voiceUserId,
|
|
|
|
} = voiceUser;
|
2018-01-16 00:47:19 +08:00
|
|
|
|
2018-07-17 01:03:01 +08:00
|
|
|
const isDialInUser = (userId, meetingID) => !!Users.findOne({ meetingId: meetingID, userId, clientType: 'dial-in-user' });
|
2018-01-16 00:47:19 +08:00
|
|
|
|
|
|
|
// if the user is dial-in, leaving voice also means leaving userlist
|
2018-07-17 01:03:01 +08:00
|
|
|
if (isDialInUser(voiceUserId, meetingId)) removeUser(meetingId, intId);
|
2017-12-08 04:50:50 +08:00
|
|
|
|
2017-08-01 03:36:41 +08:00
|
|
|
return removeVoiceUser(meetingId, voiceUser);
|
|
|
|
}
|