bigbluebutton-Github/bigbluebutton-html5/imports/api/2.0/voice-users/server/modifiers/addVoiceUser.js
2017-08-01 10:10:12 -03:00

44 lines
926 B
JavaScript
Executable File

import { check } from 'meteor/check';
import Logger from '/imports/startup/server/logger';
import VoiceUsers from '/imports/api/2.0/voice-users';
import flat from 'flat';
export default function addVoiceUser(meetingId, voiceUser) {
check(meetingId, String);
check(voiceUser, {
voiceUserId: String,
intId: String,
callerName: String,
callerNum: String,
muted: Boolean,
talking: Boolean,
callingWith: String,
listenOnly: Boolean,
voiceConf: String,
});
const { intId } = voiceUser;
const selector = {
meetingId,
intId,
};
const modifier = {
$set: Object.assign(
{ meetingId },
flat(voiceUser),
),
};
const cb = (err) => {
if (err) {
return Logger.error(`Add voice user=${intId}: ${err}`);
}
return Logger.verbose(`Add voice user=${intId} meeting=${meetingId}`);
};
return VoiceUsers.upsert(selector, modifier, cb);
}