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

41 lines
839 B
JavaScript
Raw Normal View History

2017-08-01 03:36:41 +08:00
import { Match, check } from 'meteor/check';
import Logger from '/imports/startup/server/logger';
import VoiceUsers from '/imports/api/voice-users';
2017-08-01 03:36:41 +08:00
import flat from 'flat';
2017-10-18 20:30:33 +08:00
export default function updateVoiceUser(meetingId, voiceUser) {
2017-08-01 03:36:41 +08:00
check(meetingId, String);
check(voiceUser, {
intId: String,
voiceUserId: String,
talking: Match.Maybe(Boolean),
muted: Match.Maybe(Boolean),
2017-08-01 21:10:12 +08:00
voiceConf: String,
joined: Match.Maybe(Boolean),
2017-08-01 03:36:41 +08:00
});
2017-08-02 00:04:20 +08:00
const { intId } = voiceUser;
2017-08-01 03:36:41 +08:00
const selector = {
meetingId,
2017-08-02 00:04:20 +08:00
intId,
2017-08-01 03:36:41 +08:00
};
const modifier = {
$set: Object.assign(
{ meetingId },
flat(voiceUser),
),
};
const cb = (err) => {
if (err) {
2017-08-02 00:04:20 +08:00
return Logger.error(`Update voiceUser=${intId}: ${err}`);
2017-08-01 03:36:41 +08:00
}
return true;
2017-08-01 03:36:41 +08:00
};
2017-08-01 21:10:12 +08:00
return VoiceUsers.update(selector, modifier, cb);
2017-08-01 03:36:41 +08:00
}