bigbluebutton-Github/bigbluebutton-html5/imports/api/users/server/handlers/getUsers.js

28 lines
686 B
JavaScript
Raw Normal View History

import { check } from 'meteor/check';
import Users from '/imports/api/users/';
import addUser from '../modifiers/addUser';
import removeUser from '../modifiers/removeUser';
2017-10-12 09:02:23 +08:00
export default function handleGetUsers({ body }, meetingId) {
const { users } = body;
check(meetingId, String);
check(users, Array);
2017-10-12 09:02:23 +08:00
const usersIds = users.map(m => m.intId);
const usersToRemove = Users.find({
meetingId,
userId: { $nin: usersIds },
}, { fields: { userId: 1 } }).fetch();
usersToRemove.forEach(user => removeUser(meetingId, user.userId));
2017-06-03 03:25:02 +08:00
const usersAdded = [];
users.forEach((user) => {
usersAdded.push(addUser(meetingId, user));
});
return usersAdded;
2017-06-03 03:25:02 +08:00
}