bigbluebutton-Github/bigbluebutton-html5/imports/api/2.0/users/server/modifiers/updateVoiceUser.js

35 lines
877 B
JavaScript
Raw Normal View History

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-22 00:54:04 +08:00
export default function updateVoiceUser(meetingId, voiceUser) {
check(meetingId, String);
check(voiceUser, Object);
const selector = {
meetingId,
2017-06-22 00:54:04 +08:00
user: voiceUser.intId,
};
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}`);
}
if (numChanged) {
2017-06-22 00:54:04 +08:00
return Logger.verbose(`Updated voice user=${voiceUser.intId} meeting=${meetingId}`);
}
};
return Users.update(selector, modifier, cb);
}