2017-06-21 01:17:37 +08:00
|
|
|
import { check } from 'meteor/check';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
2017-06-29 02:14:29 +08:00
|
|
|
import Users from '/imports/api/2.0/users';
|
2017-06-21 01:17:37 +08:00
|
|
|
|
2017-06-22 00:54:04 +08:00
|
|
|
export default function updateVoiceUser(meetingId, voiceUser) {
|
2017-06-21 01:17:37 +08:00
|
|
|
check(meetingId, String);
|
|
|
|
check(voiceUser, Object);
|
|
|
|
|
|
|
|
const selector = {
|
|
|
|
meetingId,
|
2017-06-22 00:54:04 +08:00
|
|
|
user: voiceUser.intId,
|
2017-06-21 01:17:37 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const modifier = {
|
|
|
|
$set: {
|
|
|
|
'user.voiceUser.talking': voiceUser.talking,
|
|
|
|
'user.voiceUser.joined': voiceUser.joined,
|
|
|
|
'user.voiceUser.locked': voiceUser.locked,
|
|
|
|
'user.voiceUser.muted': voiceUser.muted,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const cb = (err, numChanged) => {
|
|
|
|
if (err) {
|
2017-06-22 00:54:04 +08:00
|
|
|
return Logger.error(`Updating voice user=${voiceUser.intId}: ${err}`);
|
2017-06-21 01:17:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (numChanged) {
|
2017-06-22 00:54:04 +08:00
|
|
|
return Logger.verbose(`Updated voice user=${voiceUser.intId} meeting=${meetingId}`);
|
2017-06-21 01:17:37 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
return Users.update(selector, modifier, cb);
|
|
|
|
}
|