2016-05-17 02:05:44 +08:00
|
|
|
import Users from '/imports/api/users';
|
2016-05-13 01:43:59 +08:00
|
|
|
|
|
|
|
// when new lock settings including disableMic are set,
|
|
|
|
// all viewers that are in the audio bridge with a mic should be muted and locked
|
|
|
|
export function handleLockingMic(meetingId, newSettings) {
|
2016-05-16 22:35:59 +08:00
|
|
|
// send mute requests for the viewer users joined with mic
|
2016-06-28 02:24:37 +08:00
|
|
|
let userObject;
|
2016-06-28 05:48:46 +08:00
|
|
|
let results = [];
|
|
|
|
const userObjects = Users.find({
|
2016-05-16 22:35:59 +08:00
|
|
|
meetingId: meetingId,
|
|
|
|
'user.role': 'VIEWER',
|
|
|
|
'user.listenOnly': false,
|
|
|
|
'user.locked': true,
|
|
|
|
'user.voiceUser.joined': true,
|
|
|
|
'user.voiceUser.muted': false,
|
|
|
|
}).fetch();
|
2016-06-28 05:48:46 +08:00
|
|
|
const _userObjectsLength = userObjects.length;
|
2016-05-13 01:43:59 +08:00
|
|
|
|
2016-06-28 02:24:37 +08:00
|
|
|
for (let i = 0; i < _userObjectsLength; i++) {
|
2016-05-16 22:35:59 +08:00
|
|
|
userObject = userObjects[i];
|
|
|
|
results.push(Meteor.call('muteUser', meetingId, userObject.userId, userObject.userId,
|
|
|
|
userObject.authToken, true)); //true for muted
|
|
|
|
}
|
2016-05-13 01:43:59 +08:00
|
|
|
|
2016-05-16 22:35:59 +08:00
|
|
|
return results;
|
2016-05-13 01:43:59 +08:00
|
|
|
};
|